exo-jcr SVN: r3002 - jcr/branches/1.14-ISPN/exo.jcr.component.core/src/test/resources/conf/standalone.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-08-30 03:00:21 -0400 (Mon, 30 Aug 2010)
New Revision: 3002
Removed:
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml
Log:
EXOJCR-831: delete test-jcr-config.xml
Deleted: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml 2010-08-30 06:56:05 UTC (rev 3001)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml 2010-08-30 07:00:21 UTC (rev 3002)
@@ -1,469 +0,0 @@
-<?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.
-
--->
-<repository-service default-repository="db1">
- <repositories>
- <repository name="db1" system-workspace="ws" default-workspace="ws">
- <security-domain>exo-domain</security-domain>
- <!-- access-control>optional</access-control -->
- <!-- access-control>disable</access-control -->
- <session-max-age>1h</session-max-age>
- <authentication-policy>org.exoplatform.services.jcr.impl.core.access.JAASAuthenticator</authentication-policy>
- <workspaces>
- <workspace name="ws">
- <!-- for system storage -->
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcr" />
- <property name="dialect" value="auto" />
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false" />
- <property name="max-buffer-size" value="200k" />
- <property name="swap-directory" value="target/temp/swap/ws" />
- </properties>
- <value-storages>
- <value-storage id="ws" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path" value="target/temp/values/ws" />
- <property name="digest-algo" value="MD5" />
- <property name="vcas-type" value="org.exoplatform.services.jcr.impl.storage.value.cas.JDBCValueContentAddressStorageImpl" />
- <property name="jdbc-source-name" value="jdbcjcr" />
- <property name="jdbc-dialect" value="auto" />
- </properties>
- <filters>
- <filter property-type="Binary" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <initializer class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
- <properties>
- <property name="root-nodetype" value="nt:unstructured" />
- </properties>
- </initializer>
- <cache enabled="true" class="org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.ISPNCacheWorkspaceStorageCache">
- <properties>
- <property name="infinispan-configuration" value="conf/standalone/test-infinispan-config.xml" />
- </properties>
- </cache>
- <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir" value="target/temp/index/db1/ws" />
- </properties>
- </query-handler>
- <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.infinispan.ISPNCacheableLockManagerImpl">
- <properties>
- <property name="time-out" value="15m" />
- <property name="infinispan-configuration" value="conf/standalone/test-infinispan-config.xml" />
- <property name="infinispan-cl-cache.jdbc.table.name" value="jcrlocks_db1_ws" />
- <property name="infinispan-cl-cache.jdbc.table.create" value="true" />
- <property name="infinispan-cl-cache.jdbc.table.drop" value="false" />
- <property name="infinispan-cl-cache.jdbc.id.column" value="id" />
- <property name="infinispan-cl-cache.jdbc.data.column" value="data" />
- <property name="infinispan-cl-cache.jdbc.timestamp.column" value="timestamp" />
- <property name="infinispan-cl-cache.jdbc.datasource" value="jdbcjcr" />
- <property name="infinispan-cl-cache.jdbc.connectionFactory" value="org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory" />
- </properties>
- </lock-manager>
- </workspace>
-
- <workspace name="ws1">
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcr1" />
- <property name="dialect" value="auto" />
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false" />
- <property name="max-buffer-size" value="200k" />
- <property name="swap-directory" value="target/temp/swap/ws1" />
- </properties>
- <value-storages>
- <value-storage id="ws1" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path" value="target/temp/values/ws1" />
- </properties>
- <filters>
- <filter property-type="Binary" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <cache enabled="true" class="org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.ISPNCacheWorkspaceStorageCache">
- <properties>
- <property name="infinispan-configuration" value="conf/standalone/test-infinispan-config.xml" />
- </properties>
- </cache>
- <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir" value="target/temp/index/db1/ws1" />
- <property name="synonymprovider-class" value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider" />
- <property name="synonymprovider-config-path" value="../../synonyms.properties" />
- <property name="support-highlighting" value="true" />
- <property name="indexing-configuration-path" value="../../indexing-configuration.xml" />
- <property name="query-class" value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
- <property name="spellchecker-class" value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval" />
- </properties>
- </query-handler>
- <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.infinispan.ISPNCacheableLockManagerImpl">
- <properties>
- <property name="time-out" value="15m" />
- <property name="infinispan-configuration" value="conf/standalone/test-infinispan-config.xml" />
- <property name="infinispan-cl-cache.jdbc.table.name" value="jcrlocks_db1_ws1" />
- <property name="infinispan-cl-cache.jdbc.table.create" value="true" />
- <property name="infinispan-cl-cache.jdbc.table.drop" value="false" />
- <property name="infinispan-cl-cache.jdbc.id.column" value="id" />
- <property name="infinispan-cl-cache.jdbc.data.column" value="data" />
- <property name="infinispan-cl-cache.jdbc.timestamp.column" value="timestamp" />
- <property name="infinispan-cl-cache.jdbc.datasource" value="jdbcjcr1" />
- <property name="infinispan-cl-cache.jdbc.connectionFactory" value="org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory" />
- </properties>
- </lock-manager>
- </workspace>
-
- <workspace name="ws2" lazy-read-threshold="1">
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcr2" />
- <property name="dialect" value="auto" />
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false" />
- <property name="max-buffer-size" value="200k" />
- <property name="swap-directory" value="target/temp/swap/ws2" />
- </properties>
- <value-storages>
- <value-storage id="ws2" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path" value="target/temp/values/ws2" />
- </properties>
- <filters>
- <filter property-type="Binary" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <cache enabled="true" class="org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.ISPNCacheWorkspaceStorageCache">
- <properties>
- <property name="infinispan-configuration" value="conf/standalone/test-infinispan-config.xml" />
- </properties>
- </cache>
- <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir" value="target/temp/index/db1/ws2" />
- <property name="synonymprovider-class" value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider" />
- <property name="synonymprovider-config-path" value="../../synonyms.properties" />
- <property name="support-highlighting" value="true" />
- <property name="indexing-configuration-path" value="../../indexing-configuration.xml" />
- <property name="query-class" value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
- <property name="spellchecker-class" value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval" />
- </properties>
- </query-handler>
- <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.infinispan.ISPNCacheableLockManagerImpl">
- <properties>
- <property name="time-out" value="15m" />
- <property name="infinispan-configuration" value="conf/standalone/test-infinispan-config.xml" />
- <property name="infinispan-cl-cache.jdbc.table.name" value="jcrlocks_db1_ws2" />
- <property name="infinispan-cl-cache.jdbc.table.create" value="true" />
- <property name="infinispan-cl-cache.jdbc.table.drop" value="false" />
- <property name="infinispan-cl-cache.jdbc.id.column" value="id" />
- <property name="infinispan-cl-cache.jdbc.data.column" value="data" />
- <property name="infinispan-cl-cache.jdbc.timestamp.column" value="timestamp" />
- <property name="infinispan-cl-cache.jdbc.datasource" value="jdbcjcr2" />
- <property name="infinispan-cl-cache.jdbc.connectionFactory" value="org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory" />
- </properties>
- </lock-manager>
- </workspace>
-
- <workspace name="ws3">
- <!-- for system storage -->
- <container
- class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcr3" />
- <property name="dialect" value="auto" />
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false" />
- <property name="max-buffer-size" value="200k" />
- <property name="swap-directory" value="target/temp/swap/ws3" />
- </properties>
- <value-storages>
- <!--
- This storage is used to check whether properties are removed
- correctly from each value-storage
- (TestRemoveFromValueStorage.java)
- -->
- <value-storage id="ws3_big"
- class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path" value="target/temp/values/ws3_big" />
- </properties>
- <filters>
- <filter property-type="Binary" min-value-size="1024K" />
- </filters>
- </value-storage>
- <value-storage id="ws3"
- class="org.exoplatform.services.jcr.impl.storage.value.fs.CASableTreeFileValueStorage">
- <properties>
- <property name="path" value="target/temp/values/ws3" />
- <property name="digest-algo" value="MD5" />
- <property name="vcas-type"
- value="org.exoplatform.services.jcr.impl.storage.value.cas.JDBCValueContentAddressStorageImpl" />
- <property name="jdbc-source-name" value="jdbcjcr" />
- </properties>
- <filters>
- <filter property-type="Binary" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <initializer
- class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
- <properties>
- <property name="root-nodetype" value="nt:unstructured" />
- </properties>
- </initializer>
- <cache enabled="true" class="org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.ISPNCacheWorkspaceStorageCache">
- <properties>
- <property name="infinispan-configuration" value="conf/standalone/test-infinispan-config.xml" />
- </properties>
- </cache>
- <query-handler
- class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir" value="target/temp/index/db1/ws3" />
- <property name="synonymprovider-class"
- value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider" />
- <property name="synonymprovider-config-path" value="../../synonyms.properties" />
- <property name="support-highlighting" value="true" />
- <property name="indexing-configuration-path" value="../../indexing-configuration.xml" />
- <property name="query-class" value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
- <property name="spellchecker-class" value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval" />
- </properties>
- </query-handler>
- <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.infinispan.ISPNCacheableLockManagerImpl">
- <properties>
- <property name="time-out" value="15m" />
- <property name="infinispan-configuration" value="conf/standalone/test-infinispan-config.xml" />
- <property name="infinispan-cl-cache.jdbc.table.name" value="jcrlocks_db1_ws3" />
- <property name="infinispan-cl-cache.jdbc.table.create" value="true" />
- <property name="infinispan-cl-cache.jdbc.table.drop" value="false" />
- <property name="infinispan-cl-cache.jdbc.id.column" value="id" />
- <property name="infinispan-cl-cache.jdbc.data.column" value="data" />
- <property name="infinispan-cl-cache.jdbc.timestamp.column" value="timestamp" />
- <property name="infinispan-cl-cache.jdbc.datasource" value="jdbcjcr3" />
- <property name="infinispan-cl-cache.jdbc.connectionFactory" value="org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory" />
- </properties>
- </lock-manager>
- </workspace>
- </workspaces>
- </repository>
-
- <repository name="db1tck" system-workspace="ws" default-workspace="ws">
- <security-domain>exo-domain</security-domain>
- <!-- access-control>optional</access-control -->
- <!-- access-control>disable</access-control -->
- <session-max-age>1h</session-max-age>
- <authentication-policy>org.exoplatform.services.jcr.impl.core.access.JAASAuthenticator</authentication-policy>
- <workspaces>
- <workspace name="ws">
- <!-- for system storage -->
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcrtck" />
- <property name="dialect" value="auto" />
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false" />
- <property name="max-buffer-size" value="200k" />
- <property name="swap-directory" value="target/temp/swap/wstck" />
- </properties>
- <value-storages>
- <value-storage id="ws" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path" value="target/temp/values/wstck" />
- </properties>
- <filters>
- <filter property-type="Binary" min-value-size="100K" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <initializer class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
- <properties>
- <property name="root-nodetype" value="nt:unstructured" />
- <property name="root-permissions" value="any read;*:/platform/administrators read;*:/platform/administrators add_node;*:/platform/administrators set_property;*:/platform/administrators remove" />
- </properties>
- </initializer>
- <cache enabled="true" class="org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.ISPNCacheWorkspaceStorageCache">
- <properties>
- <property name="infinispan-configuration" value="conf/standalone/test-infinispan-config.xml" />
- </properties>
- </cache>
- <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir" value="target/temp/index/db1tck/ws" />
- <property name="synonymprovider-class" value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider" />
- <property name="synonymprovider-config-path" value="../../synonyms.properties" />
- <property name="support-highlighting" value="true" />
- <property name="indexing-configuration-path" value="../../indexing-configuration.xml" />
- <property name="query-class" value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
- <property name="excerptprovider-class" value="org.exoplatform.services.jcr.impl.core.query.lucene.WeightedHTMLExcerpt" />
- <property name="spellchecker-class" value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval" />
- </properties>
- </query-handler>
- <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.infinispan.ISPNCacheableLockManagerImpl">
- <properties>
- <property name="time-out" value="15m" />
- <property name="infinispan-configuration" value="conf/standalone/test-infinispan-config.xml" />
- <property name="infinispan-cl-cache.jdbc.table.name" value="jcrlocks_db1tck_ws" />
- <property name="infinispan-cl-cache.jdbc.table.create" value="true" />
- <property name="infinispan-cl-cache.jdbc.table.drop" value="false" />
- <property name="infinispan-cl-cache.jdbc.id.column" value="id" />
- <property name="infinispan-cl-cache.jdbc.data.column" value="data" />
- <property name="infinispan-cl-cache.jdbc.timestamp.column" value="timestamp" />
- <property name="infinispan-cl-cache.jdbc.datasource" value="jdbcjcrtck" />
- <property name="infinispan-cl-cache.jdbc.connectionFactory" value="org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory" />
- </properties>
- </lock-manager>
- </workspace>
-
- <workspace name="ws1">
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcr1tck" />
- <property name="dialect" value="auto" />
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false" />
- <property name="max-buffer-size" value="200k" />
- <property name="swap-directory" value="target/temp/swap/ws1tck" />
- </properties>
- <value-storages>
- <value-storage id="ws1" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path" value="target/temp/values/ws1tck" />
- </properties>
- <filters>
- <filter property-type="Binary" min-value-size="100K" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <initializer class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
- <properties>
- <property name="root-nodetype" value="nt:unstructured" />
- <property name="root-permissions" value="any read;*:/platform/administrators read;*:/platform/administrators add_node;*:/platform/administrators set_property;*:/platform/administrators remove" />
- </properties>
- </initializer>
- <cache enabled="true" class="org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.ISPNCacheWorkspaceStorageCache">
- <properties>
- <property name="infinispan-configuration" value="conf/standalone/test-infinispan-config.xml" />
- </properties>
- </cache>
- <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir" value="target/temp/index/db1tck/ws1" />
- <property name="synonymprovider-class" value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider" />
- <property name="synonymprovider-config-path" value="../../synonyms.properties" />
- <property name="support-highlighting" value="true" />
- <property name="indexing-configuration-path" value="../../indexing-configuration.xml" />
- <property name="query-class" value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
- <property name="spellchecker-class" value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval" />
- </properties>
- </query-handler>
- <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.infinispan.ISPNCacheableLockManagerImpl">
- <properties>
- <property name="time-out" value="15m" />
- <property name="infinispan-configuration" value="conf/standalone/test-infinispan-config.xml" />
- <property name="infinispan-cl-cache.jdbc.table.name" value="jcrlocks_db1tck_ws1" />
- <property name="infinispan-cl-cache.jdbc.table.create" value="true" />
- <property name="infinispan-cl-cache.jdbc.table.drop" value="false" />
- <property name="infinispan-cl-cache.jdbc.id.column" value="id" />
- <property name="infinispan-cl-cache.jdbc.data.column" value="data" />
- <property name="infinispan-cl-cache.jdbc.timestamp.column" value="timestamp" />
- <property name="infinispan-cl-cache.jdbc.datasource" value="jdbcjcr1tck" />
- <property name="infinispan-cl-cache.jdbc.connectionFactory" value="org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory" />
- </properties>
- </lock-manager>
- </workspace>
-
- <workspace name="ws2">
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcr2tck" />
- <property name="dialect" value="auto" />
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false" />
- <property name="max-buffer-size" value="200k" />
- <property name="swap-directory" value="target/temp/swap/ws2tck" />
- </properties>
- <value-storages>
- <value-storage id="ws2" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path" value="target/temp/values/ws2tck" />
- </properties>
- <filters>
- <filter property-type="Binary" min-value-size="100K" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <initializer class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
- <properties>
- <property name="root-nodetype" value="nt:unstructured" />
- <property name="root-permissions" value="any read;*:/platform/administrators read;*:/platform/administrators add_node;*:/platform/administrators set_property;*:/platform/administrators remove" />
- </properties>
- </initializer>
- <cache enabled="true" class="org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.ISPNCacheWorkspaceStorageCache">
- <properties>
- <property name="infinispan-configuration" value="conf/standalone/test-infinispan-config.xml" />
- </properties>
- </cache>
- <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir" value="target/temp/index/db1tck/ws2" />
- <property name="synonymprovider-class" value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider" />
- <property name="synonymprovider-config-path" value="../../synonyms.properties" />
- <property name="support-highlighting" value="true" />
- <property name="indexing-configuration-path" value="../../indexing-configuration.xml" />
- <property name="query-class" value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
- <property name="spellchecker-class" value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval" />
- <property name="excerptprovider-class" value="org.exoplatform.services.jcr.impl.core.query.lucene.WeightedHTMLExcerpt"/>
- <property name="extractorPoolSize" value="2"/>
- <property name="extractorTimeout" value="10"/>
- </properties>
- </query-handler>
- <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.infinispan.ISPNCacheableLockManagerImpl">
- <properties>
- <property name="time-out" value="15m" />
- <property name="infinispan-configuration" value="conf/standalone/test-infinispan-config.xml" />
- <property name="infinispan-cl-cache.jdbc.table.name" value="jcrlocks_db1tck_ws2" />
- <property name="infinispan-cl-cache.jdbc.table.create" value="true" />
- <property name="infinispan-cl-cache.jdbc.table.drop" value="false" />
- <property name="infinispan-cl-cache.jdbc.id.column" value="id" />
- <property name="infinispan-cl-cache.jdbc.data.column" value="data" />
- <property name="infinispan-cl-cache.jdbc.timestamp.column" value="timestamp" />
- <property name="infinispan-cl-cache.jdbc.datasource" value="jdbcjcr2tck" />
- <property name="infinispan-cl-cache.jdbc.connectionFactory" value="org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory" />
- </properties>
- </lock-manager>
- </workspace>
- </workspaces>
- </repository>
- </repositories>
-</repository-service>
13 years, 10 months
exo-jcr SVN: r3001 - in jcr/branches/1.14-ISPN/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/core/lock and 6 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-08-30 02:56:05 -0400 (Mon, 30 Aug 2010)
New Revision: 3001
Added:
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/AbstractCacheableLockManager.java
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedISPNCacheHelper.java
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheHelper.java
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/JBossCacheHelper.java
Removed:
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/AbstractCacheableLockManagerImpl.java
Modified:
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/TemplateConfigurationHelper.java
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/infinispan/ISPNCacheableLockManagerImpl.java
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedCacheHelper.java
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/InfinispanCacheFactory.java
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/ExoJBossCacheFactory.java
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/config/TestTemplateConfigurationHelper.java
Log:
EXOJCR-831: apply issue's remarks
Modified: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/TemplateConfigurationHelper.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/TemplateConfigurationHelper.java 2010-08-30 06:26:51 UTC (rev 3000)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/TemplateConfigurationHelper.java 2010-08-30 06:56:05 UTC (rev 3001)
@@ -80,20 +80,6 @@
}
/**
- * Creates instance of TemplateConfigurationHelper pre-configured for JBossCache parameters,<br>
- * including: "jbosscache-*" and "jgroups-configuration", and excluding "jbosscache-configuration"
- *
- * @param ConfigurationManager instance for looking up resources
- * @return
- */
- public static TemplateConfigurationHelper createJBossCacheHelper(ConfigurationManager cfm)
- {
- return new TemplateConfigurationHelper(
- new String[]{"^jbosscache-.*", "^jgroups-configuration", "^infinispan-.*"}, new String[]{
- "^jbosscache-configuration", "^infinispan-configuration"}, cfm);
- }
-
- /**
* Reads configuration file from a stream and replaces all the occurrences of template-variables
* (like : "${parameter.name}") with values provided in the map.
*
Added: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/AbstractCacheableLockManager.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/AbstractCacheableLockManager.java (rev 0)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/AbstractCacheableLockManager.java 2010-08-30 06:56:05 UTC (rev 3001)
@@ -0,0 +1,776 @@
+/*
+ * 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.core.lock;
+
+import org.exoplatform.management.annotations.Managed;
+import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.dataflow.ChangesLogIterator;
+import org.exoplatform.services.jcr.dataflow.CompositeChangesLog;
+import org.exoplatform.services.jcr.dataflow.DataManager;
+import org.exoplatform.services.jcr.dataflow.ItemState;
+import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
+import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
+import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
+import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
+import org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener;
+import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.core.SessionDataManager;
+import org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManager;
+import org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManagerImpl;
+import org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableSessionLockManager;
+import org.exoplatform.services.jcr.impl.core.lock.jbosscache.LockData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
+import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
+import org.exoplatform.services.jcr.observation.ExtendedEvent;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.security.IdentityConstants;
+import org.picocontainer.Startable;
+
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.lock.LockException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: AbstractCacheableLockManagerImpl.java 2806 2010-07-21 08:00:15Z tolusha $
+ */
+public abstract class AbstractCacheableLockManager implements CacheableLockManager, ItemsPersistenceListener, Startable
+{
+ /**
+ * The name to property time out.
+ */
+ public static final String TIME_OUT = "time-out";
+
+ /**
+ * Default lock time out. 30min
+ */
+ public static final long DEFAULT_LOCK_TIMEOUT = 1000 * 60 * 30;
+
+ /**
+ * Data manager.
+ */
+ protected final DataManager dataManager;
+
+ /**
+ * Run time lock time out.
+ */
+ protected long lockTimeOut;
+
+ /**
+ * Lock remover thread.
+ */
+ protected LockRemover lockRemover;
+
+ /**
+ * SessionLockManagers that uses this LockManager.
+ */
+ protected Map<String, CacheableSessionLockManager> sessionLockManagers;
+
+ /**
+ * The current Transaction Manager
+ */
+ protected TransactionManager tm;
+
+ /**
+ * Logger
+ */
+ private final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.AbstractCacheableLockManager");
+
+ protected LockActionNonTxAware<Integer, Object> getNumLocks;
+
+ protected LockActionNonTxAware<Boolean, Object> hasLocks;
+
+ protected LockActionNonTxAware<Boolean, String> isLockLive;
+
+ protected LockActionNonTxAware<Object, LockData> refresh;
+
+ protected LockActionNonTxAware<Boolean, String> lockExist;
+
+ protected LockActionNonTxAware<LockData, String> getLockDataById;
+
+ protected LockActionNonTxAware<List<LockData>, Object> getLockList;
+
+ /**
+ * Constructor.
+ *
+ * @param dataManager - workspace persistent data manager
+ * @param config - workspace entry
+ * @param transactionManager
+ * the transaction manager
+ * @throws RepositoryConfigurationException
+ */
+ public AbstractCacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config,
+ TransactionManager transactionManager) throws RepositoryConfigurationException
+ {
+ if (config.getLockManager() != null)
+ {
+ if (config.getLockManager().getParameters() != null
+ && config.getLockManager().getParameterValue(TIME_OUT, null) != null)
+ {
+ long timeOut = config.getLockManager().getParameterTime(TIME_OUT);
+ lockTimeOut = timeOut > 0 ? timeOut : DEFAULT_LOCK_TIMEOUT;
+ }
+ else
+ {
+ lockTimeOut =
+ config.getLockManager().getTimeout() > 0 ? config.getLockManager().getTimeout() : DEFAULT_LOCK_TIMEOUT;
+ }
+ }
+ else
+ {
+ lockTimeOut = DEFAULT_LOCK_TIMEOUT;
+ }
+
+ this.dataManager = dataManager;
+ this.sessionLockManagers = new ConcurrentHashMap<String, CacheableSessionLockManager>();
+ this.tm = transactionManager;
+
+ dataManager.addItemPersistenceListener(this);
+ }
+
+ @Managed
+ @ManagedDescription("Remove the expired locks")
+ public void cleanExpiredLocks()
+ {
+ removeExpired();
+ }
+
+ public long getDefaultLockTimeOut()
+ {
+ return lockTimeOut;
+ }
+
+ @Managed
+ @ManagedDescription("The number of active locks")
+ public int getNumLocks()
+ {
+ try
+ {
+ return executeLockActionNonTxAware(getNumLocks, null);
+ }
+ catch (LockException e)
+ {
+ // ignore me will never occur
+ }
+ return -1;
+ }
+
+ /**
+ * Indicates if some locks have already been created
+ */
+ protected boolean hasLocks()
+ {
+ try
+ {
+ return executeLockActionNonTxAware(hasLocks, null);
+ }
+ catch (LockException e)
+ {
+ // ignore me will never occur
+ }
+ return true;
+ }
+
+ /**
+ * Return new instance of session lock manager.
+ */
+ public SessionLockManager getSessionLockManager(String sessionId, SessionDataManager transientManager)
+ {
+ CacheableSessionLockManager sessionManager = new CacheableSessionLockManager(sessionId, this, transientManager);
+ sessionLockManagers.put(sessionId, sessionManager);
+ return sessionManager;
+ }
+
+ /**
+ * Check is LockManager contains lock. No matter it is in pending or persistent state.
+ *
+ * @param nodeId - locked node id
+ * @return
+ */
+ public boolean isLockLive(String nodeId) throws LockException
+ {
+ try
+ {
+ return executeLockActionNonTxAware(isLockLive, nodeId);
+ }
+ catch (LockException e)
+ {
+ // ignore me will never occur
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTXAware()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onSaveItems(ItemStateChangesLog changesLog)
+ {
+ List<PlainChangesLog> chengesLogList = new ArrayList<PlainChangesLog>();
+ if (changesLog instanceof TransactionChangesLog)
+ {
+ ChangesLogIterator logIterator = ((TransactionChangesLog)changesLog).getLogIterator();
+
+ while (logIterator.hasNextLog())
+ {
+ chengesLogList.add(logIterator.nextLog());
+ }
+ }
+ else if (changesLog instanceof PlainChangesLog)
+ {
+ chengesLogList.add((PlainChangesLog)changesLog);
+ }
+ else if (changesLog instanceof CompositeChangesLog)
+ {
+ for (ChangesLogIterator iter = ((CompositeChangesLog)changesLog).getLogIterator(); iter.hasNextLog();)
+ {
+ chengesLogList.add(iter.nextLog());
+ }
+ }
+
+ List<LockOperationContainer> containers = new ArrayList<LockOperationContainer>();
+
+ for (PlainChangesLog currChangesLog : chengesLogList)
+ {
+ String sessionId = currChangesLog.getSessionId();
+
+ String nodeIdentifier;
+ try
+ {
+ switch (currChangesLog.getEventType())
+ {
+ case ExtendedEvent.LOCK :
+ if (currChangesLog.getSize() < 2)
+ {
+ LOG.error("Incorrect changes log of type ExtendedEvent.LOCK size=" + currChangesLog.getSize()
+ + "<2 \n" + currChangesLog.dump());
+ break;
+ }
+ nodeIdentifier = currChangesLog.getAllStates().get(0).getData().getParentIdentifier();
+
+ CacheableSessionLockManager session = sessionLockManagers.get(sessionId);
+ if (session != null && session.containsPendingLock(nodeIdentifier))
+ {
+ containers.add(new LockOperationContainer(nodeIdentifier, currChangesLog.getSessionId(),
+ ExtendedEvent.LOCK));
+ }
+ else
+ {
+ LOG.error("Lock must exist in pending locks.");
+ }
+ break;
+ case ExtendedEvent.UNLOCK :
+ if (currChangesLog.getSize() < 2)
+ {
+ LOG.error("Incorrect changes log of type ExtendedEvent.UNLOCK size=" + currChangesLog.getSize()
+ + "<2 \n" + currChangesLog.dump());
+ break;
+ }
+
+ containers.add(new LockOperationContainer(currChangesLog.getAllStates().get(0).getData()
+ .getParentIdentifier(), currChangesLog.getSessionId(), ExtendedEvent.UNLOCK));
+ break;
+ default :
+ HashSet<String> removedLock = new HashSet<String>();
+ for (ItemState itemState : currChangesLog.getAllStates())
+ {
+ // this is a node and node is locked
+ if (itemState.getData().isNode() && lockExist(itemState.getData().getIdentifier()))
+ {
+ nodeIdentifier = itemState.getData().getIdentifier();
+ if (itemState.isDeleted())
+ {
+ removedLock.add(nodeIdentifier);
+ }
+ else if (itemState.isAdded() || itemState.isRenamed() || itemState.isUpdated())
+ {
+ removedLock.remove(nodeIdentifier);
+ }
+ }
+ }
+ for (String identifier : removedLock)
+ {
+ containers.add(new LockOperationContainer(identifier, currChangesLog.getSessionId(),
+ ExtendedEvent.UNLOCK));
+ }
+ break;
+ }
+ }
+ catch (IllegalStateException e)
+ {
+ LOG.error(e.getLocalizedMessage(), e);
+ }
+ }
+
+ // sort locking and unlocking operations to avoid deadlocks
+ Collections.sort(containers);
+ for (LockOperationContainer container : containers)
+ {
+ try
+ {
+ container.apply();
+ }
+ catch (LockException e)
+ {
+ LOG.error(e.getMessage(), e);
+ }
+ }
+ }
+
+ /**
+ * Class containing operation type (LOCK or UNLOCK) and all the needed information like node uuid and session id.
+ */
+ private class LockOperationContainer implements Comparable<LockOperationContainer>
+ {
+
+ private String identifier;
+
+ private String sessionId;
+
+ private int type;
+
+ /**
+ * @param identifier node identifier
+ * @param sessionId id of session
+ * @param type ExtendedEvent type specifying the operation (LOCK or UNLOCK)
+ */
+ public LockOperationContainer(String identifier, String sessionId, int type)
+ {
+ super();
+ this.identifier = identifier;
+ this.sessionId = sessionId;
+ this.type = type;
+ }
+
+ /**
+ * @return node identifier
+ */
+ public String getIdentifier()
+ {
+ return identifier;
+ }
+
+ public void apply() throws LockException
+ {
+ // invoke internalLock in LOCK operation
+ if (type == ExtendedEvent.LOCK)
+ {
+ internalLock(sessionId, identifier);
+ }
+ // invoke internalUnLock in UNLOCK operation
+ else if (type == ExtendedEvent.UNLOCK)
+ {
+ internalUnLock(sessionId, identifier);
+ }
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(LockOperationContainer o)
+ {
+ return identifier.compareTo(o.getIdentifier());
+ }
+ }
+
+ /**
+ * Refreshed lock data in cache
+ *
+ * @param newLockData
+ */
+ public void refreshLockData(LockData newLockData) throws LockException
+ {
+ executeLockActionNonTxAware(refresh, newLockData);
+ }
+
+ /**
+ * Remove expired locks. Used from LockRemover.
+ */
+ public synchronized void removeExpired()
+ {
+ final List<String> removeLockList = new ArrayList<String>();
+
+ for (LockData lock : getLockList())
+ {
+ if (!lock.isSessionScoped() && lock.getTimeToDeath() < 0)
+ {
+ removeLockList.add(lock.getNodeIdentifier());
+ }
+ }
+
+ Collections.sort(removeLockList);
+
+ for (String rLock : removeLockList)
+ {
+ removeLock(rLock);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void start()
+ {
+ lockRemover = new LockRemover(this);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void stop()
+ {
+ lockRemover.halt();
+ lockRemover.interrupt();
+ sessionLockManagers.clear();
+ }
+
+ /**
+ * Copy <code>PropertyData prop<code> to new TransientItemData
+ *
+ * @param prop
+ * @return
+ * @throws RepositoryException
+ */
+ protected TransientItemData copyItemData(PropertyData prop) throws RepositoryException
+ {
+ if (prop == null)
+ {
+ return null;
+ }
+
+ // make a copy, value may be null for deleting items
+ TransientPropertyData newData =
+ new TransientPropertyData(prop.getQPath(), prop.getIdentifier(), prop.getPersistedVersion(), prop.getType(),
+ prop.getParentIdentifier(), prop.isMultiValued(), prop.getValues());
+
+ return newData;
+ }
+
+ /**
+ * Internal lock
+ *
+ * @param nodeIdentifier
+ * @throws LockException
+ */
+ protected abstract void internalLock(String sessionId, String nodeIdentifier) throws LockException;
+
+ /**
+ * Internal unlock.
+ *
+ * @param sessionId
+ * @param nodeIdentifier
+ * @throws LockException
+ */
+ protected abstract void internalUnLock(String sessionId, String nodeIdentifier) throws LockException;
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean lockExist(String nodeId)
+ {
+ try
+ {
+ return executeLockActionNonTxAware(lockExist, nodeId);
+ }
+ catch (LockException e)
+ {
+ // ignore me will never occur
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getLockTokenHash(String token)
+ {
+ String hash = "";
+ try
+ {
+ MessageDigest m = MessageDigest.getInstance("MD5");
+ m.update(token.getBytes(), 0, token.length());
+ hash = new BigInteger(1, m.digest()).toString(16);
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+ LOG.error("Can't get instanse of MD5 MessageDigest!", e);
+ }
+ return hash;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public LockData getExactNodeOrCloseParentLock(NodeData node) throws RepositoryException
+ {
+ return getExactNodeOrCloseParentLock(node, true);
+ }
+
+ private LockData getExactNodeOrCloseParentLock(NodeData node, boolean checkHasLocks) throws RepositoryException
+ {
+
+ if (node == null || (checkHasLocks && !hasLocks()))
+ {
+ return null;
+ }
+ LockData retval = null;
+ retval = getLockDataById(node.getIdentifier());
+ if (retval == null)
+ {
+ NodeData parentData = (NodeData)dataManager.getItemData(node.getParentIdentifier());
+ if (parentData != null)
+ {
+ retval = getExactNodeOrCloseParentLock(parentData, false);
+ }
+ }
+ return retval;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public LockData getExactNodeLock(NodeData node) throws RepositoryException
+ {
+ if (node == null || !hasLocks())
+ {
+ return null;
+ }
+
+ return getLockDataById(node.getIdentifier());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public LockData getClosedChild(NodeData node) throws RepositoryException
+ {
+ return getClosedChild(node, true);
+ }
+
+ private LockData getClosedChild(NodeData node, boolean checkHasLocks) throws RepositoryException
+ {
+
+ if (node == null || (checkHasLocks && !hasLocks()))
+ {
+ return null;
+ }
+ LockData retval = null;
+
+ List<NodeData> childData = dataManager.getChildNodesData(node);
+ for (NodeData nodeData : childData)
+ {
+ retval = getLockDataById(nodeData.getIdentifier());
+ if (retval != null)
+ return retval;
+ }
+ // child not found try to find dipper
+ for (NodeData nodeData : childData)
+ {
+ retval = getClosedChild(nodeData, false);
+ if (retval != null)
+ return retval;
+ }
+ return retval;
+ }
+
+ protected LockData getLockDataById(String nodeId)
+ {
+ try
+ {
+ return executeLockActionNonTxAware(getLockDataById, nodeId);
+ }
+ catch (LockException e)
+ {
+ // ignore me will never occur
+ }
+ return null;
+ }
+
+ protected synchronized List<LockData> getLockList()
+ {
+ try
+ {
+ return executeLockActionNonTxAware(getLockList, null);
+ }
+ catch (LockException e)
+ {
+ // ignore me will never occur
+ }
+ return null;
+ }
+
+ /**
+ * Remove lock, used by Lock remover.
+ *
+ * @param nodeIdentifier String
+ */
+ protected void removeLock(String nodeIdentifier)
+ {
+ try
+ {
+ NodeData nData = (NodeData)dataManager.getItemData(nodeIdentifier);
+
+ //TODO EXOJCR-412, should be refactored in future.
+ //Skip removing, because that node was removed in other node of cluster.
+ if (nData == null)
+ {
+ return;
+ }
+
+ PlainChangesLog changesLog =
+ new PlainChangesLogImpl(new ArrayList<ItemState>(), IdentityConstants.SYSTEM, ExtendedEvent.UNLOCK);
+
+ ItemData lockOwner =
+ copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKOWNER, 1)));
+
+ //TODO EXOJCR-412, should be refactored in future.
+ //Skip removing, because that lock was removed in other node of cluster.
+ if (lockOwner == null)
+ {
+ return;
+ }
+
+ changesLog.add(ItemState.createDeletedState(lockOwner));
+
+ ItemData lockIsDeep =
+ copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKISDEEP, 1)));
+
+ //TODO EXOJCR-412, should be refactored in future.
+ //Skip removing, because that lock was removed in other node of cluster.
+ if (lockIsDeep == null)
+ {
+ return;
+ }
+
+ changesLog.add(ItemState.createDeletedState(lockIsDeep));
+
+ // lock probably removed by other thread
+ if (lockOwner == null && lockIsDeep == null)
+ {
+ return;
+ }
+
+ dataManager.save(new TransactionChangesLog(changesLog));
+ }
+ catch (JCRInvalidItemStateException e)
+ {
+ //TODO EXOJCR-412, should be refactored in future.
+ //Skip property not found in DB, because that lock property was removed in other node of cluster.
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("The propperty was removed in other node of cluster.", e);
+ }
+
+ }
+ catch (RepositoryException e)
+ {
+ LOG.error("Error occur during removing lock" + e.getLocalizedMessage(), e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void closeSessionLockManager(String sessionID)
+ {
+ sessionLockManagers.remove(sessionID);
+ }
+
+ /**
+ * Execute the given action outside a transaction. This is needed since the {@link Cache} used by {@link CacheableLockManagerImpl}
+ * manages the persistence of its locks thanks to a {@link CacheLoader} and a {@link CacheLoader} lock the JBoss cache {@link Node}
+ * even for read operations which cause deadlock issue when a XA {@link Transaction} is already opened
+ * @throws LockException when a exception occurs
+ */
+ private <R, A> R executeLockActionNonTxAware(LockActionNonTxAware<R, A> action, A arg) throws LockException
+ {
+ Transaction tx = null;
+ try
+ {
+ if (tm != null)
+ {
+ try
+ {
+ tx = tm.suspend();
+ }
+ catch (Exception e)
+ {
+ LOG.warn("Cannot suspend the current transaction", e);
+ }
+ }
+ return action.execute(arg);
+ }
+ finally
+ {
+ if (tx != null)
+ {
+ try
+ {
+ tm.resume(tx);
+ }
+ catch (Exception e)
+ {
+ LOG.warn("Cannot resume the current transaction", e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Actions that are not supposed to be called within a transaction
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 21 janv. 2010
+ */
+ protected static interface LockActionNonTxAware<R, A>
+ {
+ R execute(A arg) throws LockException;
+ }
+}
Modified: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/infinispan/ISPNCacheableLockManagerImpl.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/infinispan/ISPNCacheableLockManagerImpl.java 2010-08-30 06:26:51 UTC (rev 3000)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/infinispan/ISPNCacheableLockManagerImpl.java 2010-08-30 06:56:05 UTC (rev 3001)
@@ -24,13 +24,13 @@
import org.exoplatform.services.jcr.config.MappedParametrizedObjectEntry;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.impl.core.lock.jbosscache.AbstractCacheableLockManagerImpl;
+import org.exoplatform.services.jcr.impl.core.lock.AbstractCacheableLockManager;
import org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableSessionLockManager;
import org.exoplatform.services.jcr.impl.core.lock.jbosscache.LockData;
import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
import org.exoplatform.services.jcr.impl.storage.jdbc.DialectDetecter;
-import org.exoplatform.services.jcr.impl.util.io.PrivilegedCacheHelper;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedISPNCacheHelper;
import org.exoplatform.services.jcr.infinispan.InfinispanCacheFactory;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -60,7 +60,7 @@
*/
@Managed
@NameTemplate(@Property(key = "service", value = "lockmanager"))
-public class ISPNCacheableLockManagerImpl extends AbstractCacheableLockManagerImpl
+public class ISPNCacheableLockManagerImpl extends AbstractCacheableLockManager
{
/**
@@ -142,12 +142,7 @@
{
public Boolean execute(String nodeId)
{
- if (cache.get(nodeId) != null)
- {
- return true;
- }
-
- return false;
+ return cache.containsKey(nodeId);
}
};
@@ -155,7 +150,7 @@
{
public Object execute(LockData newLockData) throws LockException
{
- Object oldValue = PrivilegedCacheHelper.put(cache, newLockData.getNodeIdentifier(), newLockData);
+ Object oldValue = PrivilegedISPNCacheHelper.put(cache, newLockData.getNodeIdentifier(), newLockData);
if (oldValue == null)
{
throw new LockException("Can't refresh lock for node " + newLockData.getNodeIdentifier()
@@ -165,13 +160,7 @@
}
};
- this.lockExist = new LockActionNonTxAware<Boolean, String>()
- {
- public Boolean execute(String nodeId) throws LockException
- {
- return cache.get(nodeId) != null;
- }
- };
+ this.lockExist = this.isLockLive;
this.getLockDataById = new LockActionNonTxAware<LockData, String>()
{
@@ -353,7 +342,7 @@
{
super.stop();
- PrivilegedCacheHelper.stop(cache);
+ PrivilegedISPNCacheHelper.stop(cache);
}
/**
@@ -368,7 +357,7 @@
LockData lockData = session.getPendingLock(nodeIdentifier);
// this will return null if success. And old data if something exists...
- LockData oldLockData = (LockData)PrivilegedCacheHelper.put(cache, nodeIdentifier, lockData);
+ LockData oldLockData = (LockData)PrivilegedISPNCacheHelper.putIfAbsent(cache, nodeIdentifier, lockData);
if (oldLockData != null)
{
Deleted: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/AbstractCacheableLockManagerImpl.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/AbstractCacheableLockManagerImpl.java 2010-08-30 06:26:51 UTC (rev 3000)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/AbstractCacheableLockManagerImpl.java 2010-08-30 06:56:05 UTC (rev 3001)
@@ -1,775 +0,0 @@
-/*
- * 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.core.lock.jbosscache;
-
-import org.exoplatform.management.annotations.Managed;
-import org.exoplatform.management.annotations.ManagedDescription;
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.dataflow.ChangesLogIterator;
-import org.exoplatform.services.jcr.dataflow.CompositeChangesLog;
-import org.exoplatform.services.jcr.dataflow.DataManager;
-import org.exoplatform.services.jcr.dataflow.ItemState;
-import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
-import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
-import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
-import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
-import org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener;
-import org.exoplatform.services.jcr.datamodel.ItemData;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.core.SessionDataManager;
-import org.exoplatform.services.jcr.impl.core.lock.LockRemover;
-import org.exoplatform.services.jcr.impl.core.lock.SessionLockManager;
-import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
-import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
-import org.exoplatform.services.jcr.observation.ExtendedEvent;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.exoplatform.services.security.IdentityConstants;
-import org.picocontainer.Startable;
-
-import java.math.BigInteger;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.lock.LockException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date:
- *
- * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id$
- */
-public abstract class AbstractCacheableLockManagerImpl implements CacheableLockManager, ItemsPersistenceListener,
- Startable
-{
- /**
- * The name to property time out.
- */
- public static final String TIME_OUT = "time-out";
-
- /**
- * Default lock time out. 30min
- */
- public static final long DEFAULT_LOCK_TIMEOUT = 1000 * 60 * 30;
-
- /**
- * Data manager.
- */
- protected final DataManager dataManager;
-
- /**
- * Run time lock time out.
- */
- protected long lockTimeOut;
-
- /**
- * Lock remover thread.
- */
- protected LockRemover lockRemover;
-
- /**
- * SessionLockManagers that uses this LockManager.
- */
- protected Map<String, CacheableSessionLockManager> sessionLockManagers;
-
- /**
- * The current Transaction Manager
- */
- protected TransactionManager tm;
-
- /**
- * Logger
- */
- private final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.AbstractCacheableLockManagerImpl");
-
- protected LockActionNonTxAware<Integer, Object> getNumLocks;
-
- protected LockActionNonTxAware<Boolean, Object> hasLocks;
-
- protected LockActionNonTxAware<Boolean, String> isLockLive;
-
- protected LockActionNonTxAware<Object, LockData> refresh;
-
- protected LockActionNonTxAware<Boolean, String> lockExist;
-
- protected LockActionNonTxAware<LockData, String> getLockDataById;
-
- protected LockActionNonTxAware<List<LockData>, Object> getLockList;
-
- /**
- * Constructor.
- *
- * @param dataManager - workspace persistent data manager
- * @param config - workspace entry
- * @param transactionManager
- * the transaction manager
- * @throws RepositoryConfigurationException
- */
- public AbstractCacheableLockManagerImpl(WorkspacePersistentDataManager dataManager, WorkspaceEntry config,
- TransactionManager transactionManager) throws RepositoryConfigurationException
- {
- if (config.getLockManager() != null)
- {
- if (config.getLockManager().getParameters() != null
- && config.getLockManager().getParameterValue(TIME_OUT, null) != null)
- {
- long timeOut = config.getLockManager().getParameterTime(TIME_OUT);
- lockTimeOut = timeOut > 0 ? timeOut : DEFAULT_LOCK_TIMEOUT;
- }
- else
- {
- lockTimeOut =
- config.getLockManager().getTimeout() > 0 ? config.getLockManager().getTimeout() : DEFAULT_LOCK_TIMEOUT;
- }
- }
- else
- {
- lockTimeOut = DEFAULT_LOCK_TIMEOUT;
- }
-
- this.dataManager = dataManager;
- this.sessionLockManagers = new ConcurrentHashMap<String, CacheableSessionLockManager>();
- this.tm = transactionManager;
-
- dataManager.addItemPersistenceListener(this);
- }
-
- @Managed
- @ManagedDescription("Remove the expired locks")
- public void cleanExpiredLocks()
- {
- removeExpired();
- }
-
- public long getDefaultLockTimeOut()
- {
- return lockTimeOut;
- }
-
- @Managed
- @ManagedDescription("The number of active locks")
- public int getNumLocks()
- {
- try
- {
- return executeLockActionNonTxAware(getNumLocks, null);
- }
- catch (LockException e)
- {
- // ignore me will never occur
- }
- return -1;
- }
-
- /**
- * Indicates if some locks have already been created
- */
- protected boolean hasLocks()
- {
- try
- {
- return executeLockActionNonTxAware(hasLocks, null);
- }
- catch (LockException e)
- {
- // ignore me will never occur
- }
- return true;
- }
-
- /**
- * Return new instance of session lock manager.
- */
- public SessionLockManager getSessionLockManager(String sessionId, SessionDataManager transientManager)
- {
- CacheableSessionLockManager sessionManager = new CacheableSessionLockManager(sessionId, this, transientManager);
- sessionLockManagers.put(sessionId, sessionManager);
- return sessionManager;
- }
-
- /**
- * Check is LockManager contains lock. No matter it is in pending or persistent state.
- *
- * @param nodeId - locked node id
- * @return
- */
- public boolean isLockLive(String nodeId) throws LockException
- {
- try
- {
- return executeLockActionNonTxAware(isLockLive, nodeId);
- }
- catch (LockException e)
- {
- // ignore me will never occur
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isTXAware()
- {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public void onSaveItems(ItemStateChangesLog changesLog)
- {
- List<PlainChangesLog> chengesLogList = new ArrayList<PlainChangesLog>();
- if (changesLog instanceof TransactionChangesLog)
- {
- ChangesLogIterator logIterator = ((TransactionChangesLog)changesLog).getLogIterator();
-
- while (logIterator.hasNextLog())
- {
- chengesLogList.add(logIterator.nextLog());
- }
- }
- else if (changesLog instanceof PlainChangesLog)
- {
- chengesLogList.add((PlainChangesLog)changesLog);
- }
- else if (changesLog instanceof CompositeChangesLog)
- {
- for (ChangesLogIterator iter = ((CompositeChangesLog)changesLog).getLogIterator(); iter.hasNextLog();)
- {
- chengesLogList.add(iter.nextLog());
- }
- }
-
- List<LockOperationContainer> containers = new ArrayList<LockOperationContainer>();
-
- for (PlainChangesLog currChangesLog : chengesLogList)
- {
- String sessionId = currChangesLog.getSessionId();
-
- String nodeIdentifier;
- try
- {
- switch (currChangesLog.getEventType())
- {
- case ExtendedEvent.LOCK :
- if (currChangesLog.getSize() < 2)
- {
- LOG.error("Incorrect changes log of type ExtendedEvent.LOCK size=" + currChangesLog.getSize()
- + "<2 \n" + currChangesLog.dump());
- break;
- }
- nodeIdentifier = currChangesLog.getAllStates().get(0).getData().getParentIdentifier();
-
- CacheableSessionLockManager session = sessionLockManagers.get(sessionId);
- if (session != null && session.containsPendingLock(nodeIdentifier))
- {
- containers.add(new LockOperationContainer(nodeIdentifier, currChangesLog.getSessionId(),
- ExtendedEvent.LOCK));
- }
- else
- {
- LOG.error("Lock must exist in pending locks.");
- }
- break;
- case ExtendedEvent.UNLOCK :
- if (currChangesLog.getSize() < 2)
- {
- LOG.error("Incorrect changes log of type ExtendedEvent.UNLOCK size=" + currChangesLog.getSize()
- + "<2 \n" + currChangesLog.dump());
- break;
- }
-
- containers.add(new LockOperationContainer(currChangesLog.getAllStates().get(0).getData()
- .getParentIdentifier(), currChangesLog.getSessionId(), ExtendedEvent.UNLOCK));
- break;
- default :
- HashSet<String> removedLock = new HashSet<String>();
- for (ItemState itemState : currChangesLog.getAllStates())
- {
- // this is a node and node is locked
- if (itemState.getData().isNode() && lockExist(itemState.getData().getIdentifier()))
- {
- nodeIdentifier = itemState.getData().getIdentifier();
- if (itemState.isDeleted())
- {
- removedLock.add(nodeIdentifier);
- }
- else if (itemState.isAdded() || itemState.isRenamed() || itemState.isUpdated())
- {
- removedLock.remove(nodeIdentifier);
- }
- }
- }
- for (String identifier : removedLock)
- {
- containers.add(new LockOperationContainer(identifier, currChangesLog.getSessionId(),
- ExtendedEvent.UNLOCK));
- }
- break;
- }
- }
- catch (IllegalStateException e)
- {
- LOG.error(e.getLocalizedMessage(), e);
- }
- }
-
- // sort locking and unlocking operations to avoid deadlocks
- Collections.sort(containers);
- for (LockOperationContainer container : containers)
- {
- try
- {
- container.apply();
- }
- catch (LockException e)
- {
- LOG.error(e.getMessage(), e);
- }
- }
- }
-
- /**
- * Class containing operation type (LOCK or UNLOCK) and all the needed information like node uuid and session id.
- */
- private class LockOperationContainer implements Comparable<LockOperationContainer>
- {
-
- private String identifier;
-
- private String sessionId;
-
- private int type;
-
- /**
- * @param identifier node identifier
- * @param sessionId id of session
- * @param type ExtendedEvent type specifying the operation (LOCK or UNLOCK)
- */
- public LockOperationContainer(String identifier, String sessionId, int type)
- {
- super();
- this.identifier = identifier;
- this.sessionId = sessionId;
- this.type = type;
- }
-
- /**
- * @return node identifier
- */
- public String getIdentifier()
- {
- return identifier;
- }
-
- public void apply() throws LockException
- {
- // invoke internalLock in LOCK operation
- if (type == ExtendedEvent.LOCK)
- {
- internalLock(sessionId, identifier);
- }
- // invoke internalUnLock in UNLOCK operation
- else if (type == ExtendedEvent.UNLOCK)
- {
- internalUnLock(sessionId, identifier);
- }
- }
-
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo(LockOperationContainer o)
- {
- return identifier.compareTo(o.getIdentifier());
- }
- }
-
- /**
- * Refreshed lock data in cache
- *
- * @param newLockData
- */
- public void refreshLockData(LockData newLockData) throws LockException
- {
- executeLockActionNonTxAware(refresh, newLockData);
- }
-
- /**
- * Remove expired locks. Used from LockRemover.
- */
- public synchronized void removeExpired()
- {
- final List<String> removeLockList = new ArrayList<String>();
-
- for (LockData lock : getLockList())
- {
- if (!lock.isSessionScoped() && lock.getTimeToDeath() < 0)
- {
- removeLockList.add(lock.getNodeIdentifier());
- }
- }
-
- Collections.sort(removeLockList);
-
- for (String rLock : removeLockList)
- {
- removeLock(rLock);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void start()
- {
- lockRemover = new LockRemover(this);
- }
-
- /**
- * {@inheritDoc}
- */
- public void stop()
- {
- lockRemover.halt();
- lockRemover.interrupt();
- sessionLockManagers.clear();
- }
-
- /**
- * Copy <code>PropertyData prop<code> to new TransientItemData
- *
- * @param prop
- * @return
- * @throws RepositoryException
- */
- protected TransientItemData copyItemData(PropertyData prop) throws RepositoryException
- {
- if (prop == null)
- {
- return null;
- }
-
- // make a copy, value may be null for deleting items
- TransientPropertyData newData =
- new TransientPropertyData(prop.getQPath(), prop.getIdentifier(), prop.getPersistedVersion(), prop.getType(),
- prop.getParentIdentifier(), prop.isMultiValued(), prop.getValues());
-
- return newData;
- }
-
- /**
- * Internal lock
- *
- * @param nodeIdentifier
- * @throws LockException
- */
- protected abstract void internalLock(String sessionId, String nodeIdentifier) throws LockException;
-
- /**
- * Internal unlock.
- *
- * @param sessionId
- * @param nodeIdentifier
- * @throws LockException
- */
- protected abstract void internalUnLock(String sessionId, String nodeIdentifier) throws LockException;
-
- /**
- * {@inheritDoc}
- */
- public boolean lockExist(String nodeId)
- {
- try
- {
- return executeLockActionNonTxAware(lockExist, nodeId);
- }
- catch (LockException e)
- {
- // ignore me will never occur
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getLockTokenHash(String token)
- {
- String hash = "";
- try
- {
- MessageDigest m = MessageDigest.getInstance("MD5");
- m.update(token.getBytes(), 0, token.length());
- hash = new BigInteger(1, m.digest()).toString(16);
- }
- catch (NoSuchAlgorithmException e)
- {
- LOG.error("Can't get instanse of MD5 MessageDigest!", e);
- }
- return hash;
- }
-
- /**
- * {@inheritDoc}
- */
- public LockData getExactNodeOrCloseParentLock(NodeData node) throws RepositoryException
- {
- return getExactNodeOrCloseParentLock(node, true);
- }
-
- private LockData getExactNodeOrCloseParentLock(NodeData node, boolean checkHasLocks) throws RepositoryException
- {
-
- if (node == null || (checkHasLocks && !hasLocks()))
- {
- return null;
- }
- LockData retval = null;
- retval = getLockDataById(node.getIdentifier());
- if (retval == null)
- {
- NodeData parentData = (NodeData)dataManager.getItemData(node.getParentIdentifier());
- if (parentData != null)
- {
- retval = getExactNodeOrCloseParentLock(parentData, false);
- }
- }
- return retval;
- }
-
- /**
- * {@inheritDoc}
- */
- public LockData getExactNodeLock(NodeData node) throws RepositoryException
- {
- if (node == null || !hasLocks())
- {
- return null;
- }
-
- return getLockDataById(node.getIdentifier());
- }
-
- /**
- * {@inheritDoc}
- */
- public LockData getClosedChild(NodeData node) throws RepositoryException
- {
- return getClosedChild(node, true);
- }
-
- private LockData getClosedChild(NodeData node, boolean checkHasLocks) throws RepositoryException
- {
-
- if (node == null || (checkHasLocks && !hasLocks()))
- {
- return null;
- }
- LockData retval = null;
-
- List<NodeData> childData = dataManager.getChildNodesData(node);
- for (NodeData nodeData : childData)
- {
- retval = getLockDataById(nodeData.getIdentifier());
- if (retval != null)
- return retval;
- }
- // child not found try to find dipper
- for (NodeData nodeData : childData)
- {
- retval = getClosedChild(nodeData, false);
- if (retval != null)
- return retval;
- }
- return retval;
- }
-
- protected LockData getLockDataById(String nodeId)
- {
- try
- {
- return executeLockActionNonTxAware(getLockDataById, nodeId);
- }
- catch (LockException e)
- {
- // ignore me will never occur
- }
- return null;
- }
-
- protected synchronized List<LockData> getLockList()
- {
- try
- {
- return executeLockActionNonTxAware(getLockList, null);
- }
- catch (LockException e)
- {
- // ignore me will never occur
- }
- return null;
- }
-
- /**
- * Remove lock, used by Lock remover.
- *
- * @param nodeIdentifier String
- */
- protected void removeLock(String nodeIdentifier)
- {
- try
- {
- NodeData nData = (NodeData)dataManager.getItemData(nodeIdentifier);
-
- //TODO EXOJCR-412, should be refactored in future.
- //Skip removing, because that node was removed in other node of cluster.
- if (nData == null)
- {
- return;
- }
-
- PlainChangesLog changesLog =
- new PlainChangesLogImpl(new ArrayList<ItemState>(), IdentityConstants.SYSTEM, ExtendedEvent.UNLOCK);
-
- ItemData lockOwner =
- copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKOWNER, 1)));
-
- //TODO EXOJCR-412, should be refactored in future.
- //Skip removing, because that lock was removed in other node of cluster.
- if (lockOwner == null)
- {
- return;
- }
-
- changesLog.add(ItemState.createDeletedState(lockOwner));
-
- ItemData lockIsDeep =
- copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKISDEEP, 1)));
-
- //TODO EXOJCR-412, should be refactored in future.
- //Skip removing, because that lock was removed in other node of cluster.
- if (lockIsDeep == null)
- {
- return;
- }
-
- changesLog.add(ItemState.createDeletedState(lockIsDeep));
-
- // lock probably removed by other thread
- if (lockOwner == null && lockIsDeep == null)
- {
- return;
- }
-
- dataManager.save(new TransactionChangesLog(changesLog));
- }
- catch (JCRInvalidItemStateException e)
- {
- //TODO EXOJCR-412, should be refactored in future.
- //Skip property not found in DB, because that lock property was removed in other node of cluster.
- if (LOG.isDebugEnabled())
- {
- LOG.debug("The propperty was removed in other node of cluster.", e);
- }
-
- }
- catch (RepositoryException e)
- {
- LOG.error("Error occur during removing lock" + e.getLocalizedMessage(), e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void closeSessionLockManager(String sessionID)
- {
- sessionLockManagers.remove(sessionID);
- }
-
- /**
- * Execute the given action outside a transaction. This is needed since the {@link Cache} used by {@link CacheableLockManagerImpl}
- * manages the persistence of its locks thanks to a {@link CacheLoader} and a {@link CacheLoader} lock the JBoss cache {@link Node}
- * even for read operations which cause deadlock issue when a XA {@link Transaction} is already opened
- * @throws LockException when a exception occurs
- */
- private <R, A> R executeLockActionNonTxAware(LockActionNonTxAware<R, A> action, A arg) throws LockException
- {
- Transaction tx = null;
- try
- {
- if (tm != null)
- {
- try
- {
- tx = tm.suspend();
- }
- catch (Exception e)
- {
- LOG.warn("Cannot suspend the current transaction", e);
- }
- }
- return action.execute(arg);
- }
- finally
- {
- if (tx != null)
- {
- try
- {
- tm.resume(tx);
- }
- catch (Exception e)
- {
- LOG.warn("Cannot resume the current transaction", e);
- }
- }
- }
- }
-
- /**
- * Actions that are not supposed to be called within a transaction
- *
- * Created by The eXo Platform SAS
- * Author : Nicolas Filotto
- * nicolas.filotto(a)exoplatform.com
- * 21 janv. 2010
- */
- protected static interface LockActionNonTxAware<R, A>
- {
- R execute(A arg) throws LockException;
- }
-}
Modified: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java 2010-08-30 06:26:51 UTC (rev 3000)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java 2010-08-30 06:56:05 UTC (rev 3001)
@@ -18,40 +18,17 @@
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.management.annotations.Managed;
-import org.exoplatform.management.annotations.ManagedDescription;
import org.exoplatform.management.jmx.annotations.NameTemplate;
import org.exoplatform.management.jmx.annotations.Property;
-import org.exoplatform.services.jcr.access.SystemIdentity;
import org.exoplatform.services.jcr.config.MappedParametrizedObjectEntry;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.config.SimpleParameterEntry;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.dataflow.ChangesLogIterator;
-import org.exoplatform.services.jcr.dataflow.CompositeChangesLog;
-import org.exoplatform.services.jcr.dataflow.DataManager;
-import org.exoplatform.services.jcr.dataflow.ItemState;
-import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
-import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
-import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
-import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
-import org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener;
-import org.exoplatform.services.jcr.datamodel.ItemData;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.core.SessionDataManager;
-import org.exoplatform.services.jcr.impl.core.lock.LockRemover;
-import org.exoplatform.services.jcr.impl.core.lock.SessionLockManager;
-import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.impl.core.lock.AbstractCacheableLockManager;
import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
-import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
import org.exoplatform.services.jcr.impl.storage.jdbc.DialectDetecter;
import org.exoplatform.services.jcr.impl.util.io.PrivilegedCacheHelper;
import org.exoplatform.services.jcr.jbosscache.ExoJBossCacheFactory;
-import org.exoplatform.services.jcr.observation.ExtendedEvent;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.naming.InitialContextInitializer;
@@ -65,30 +42,21 @@
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.lock.TimeoutException;
-import org.picocontainer.Startable;
import java.io.Serializable;
-import java.math.BigInteger;
import java.security.AccessController;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
import javax.jcr.RepositoryException;
import javax.jcr.lock.LockException;
import javax.naming.InitialContext;
import javax.sql.DataSource;
-import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
/**
@@ -101,18 +69,9 @@
*/
@Managed
@NameTemplate(@Property(key = "service", value = "lockmanager"))
-public class CacheableLockManagerImpl implements CacheableLockManager, ItemsPersistenceListener, Startable
+public class CacheableLockManagerImpl extends AbstractCacheableLockManager
{
- /**
- * The name to property time out.
- */
- public static final String TIME_OUT = "time-out";
- /**
- * The name to property cache configuration.
- */
- public static final String JBOSSCACCHE_CONFIG = "jbosscache-configuration";
-
public static final String JBOSSCACHE_JDBC_CL_DATASOURCE = "jbosscache-cl-cache.jdbc.datasource";
public static final String JBOSSCACHE_JDBC_CL_NODE_COLUMN = "jbosscache-cl-cache.jdbc.node.type";
@@ -122,11 +81,6 @@
public static final String JBOSSCACHE_JDBC_CL_AUTO = "auto";
/**
- * Default lock time out. 30min
- */
- public static final long DEFAULT_LOCK_TIMEOUT = 1000 * 60 * 30;
-
- /**
* Name of lock root in jboss-cache.
*/
public static final String LOCKS = "$LOCKS";
@@ -141,36 +95,11 @@
*/
private final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.CacheableLockManagerImpl");
- /**
- * Data manager.
- */
- private final DataManager dataManager;
-
- /**
- * Run time lock time out.
- */
- private long lockTimeOut;
-
- /**
- * Lock remover thread.
- */
- private LockRemover lockRemover;
-
- /**
- * The current Transaction Manager
- */
- private TransactionManager tm;
-
private Cache<Serializable, Object> cache;
private final Fqn<String> lockRoot;
/**
- * SessionLockManagers that uses this LockManager.
- */
- private Map<String, CacheableSessionLockManager> sessionLockManagers;
-
- /**
* Constructor.
*
* @param dataManager - workspace persistent data manager
@@ -200,7 +129,6 @@
RepositoryException
{
this(dataManager, config, context, (TransactionManager)null, cfm);
-
}
/**
@@ -217,38 +145,13 @@
InitialContextInitializer context, TransactionManager transactionManager, ConfigurationManager cfm)
throws RepositoryConfigurationException, RepositoryException
{
+ super(dataManager, config, transactionManager);
+
lockRoot = Fqn.fromElements(LOCKS);
- List<SimpleParameterEntry> paramenerts = config.getLockManager().getParameters();
-
- this.dataManager = dataManager;
- if (config.getLockManager() != null)
- {
- if (paramenerts != null && config.getLockManager().getParameterValue(TIME_OUT, null) != null)
- {
- long timeOut = config.getLockManager().getParameterTime(TIME_OUT);
- lockTimeOut = timeOut > 0 ? timeOut : DEFAULT_LOCK_TIMEOUT;
- }
- else
- {
- lockTimeOut =
- config.getLockManager().getTimeout() > 0 ? config.getLockManager().getTimeout() : DEFAULT_LOCK_TIMEOUT;
- }
- }
- else
- {
- lockTimeOut = DEFAULT_LOCK_TIMEOUT;
- }
-
- sessionLockManagers = new ConcurrentHashMap<String, CacheableSessionLockManager>();
-
- dataManager.addItemPersistenceListener(this);
-
// make cache
if (config.getLockManager() != null)
{
- this.tm = transactionManager;
-
// create cache using custom factory
ExoJBossCacheFactory<Serializable, Object> factory =
new ExoJBossCacheFactory<Serializable, Object>(cfm, transactionManager);
@@ -274,13 +177,92 @@
{
throw new RepositoryConfigurationException("Cache configuration not found");
}
+
+ this.getNumLocks = new LockActionNonTxAware<Integer, Object>()
+ {
+ public Integer execute(Object arg)
+ {
+ return ((CacheSPI<Serializable, Object>)cache).getNumberOfNodes() - 1;
+ }
+ };
+
+ this.hasLocks = new LockActionNonTxAware<Boolean, Object>()
+ {
+ public Boolean execute(Object arg)
+ {
+ return ((CacheSPI<Serializable, Object>)cache).getNode(lockRoot).hasChildrenDirect();
+ }
+ };
+
+ this.isLockLive = new LockActionNonTxAware<Boolean, String>()
+ {
+ public Boolean execute(String nodeId)
+ {
+ if (cache.get(makeLockFqn(nodeId), LOCK_DATA) != null) //pendingLocks.containsKey(nodeId) ||
+ {
+ return true;
+ }
+
+ return false;
+ }
+ };
+
+ this.refresh = new LockActionNonTxAware<Object, LockData>()
+ {
+ public Object execute(LockData newLockData) throws LockException
+ {
+ Fqn<String> fqn = makeLockFqn(newLockData.getNodeIdentifier());
+ Object oldValue = PrivilegedCacheHelper.put(cache, fqn, LOCK_DATA, newLockData);
+ if (oldValue == null)
+ {
+ throw new LockException("Can't refresh lock for node " + newLockData.getNodeIdentifier()
+ + " since lock is not exist");
+ }
+ return null;
+ }
+ };
+
+ this.lockExist = new LockActionNonTxAware<Boolean, String>()
+ {
+ public Boolean execute(String nodeId) throws LockException
+ {
+ return cache.get(makeLockFqn(nodeId), LOCK_DATA) != null;
+ }
+ };
+
+ this.getLockDataById = new LockActionNonTxAware<LockData, String>()
+ {
+ public LockData execute(String nodeId) throws LockException
+ {
+ return (LockData)cache.get(makeLockFqn(nodeId), LOCK_DATA);
+ }
+ };
+
+ this.getLockList = new LockActionNonTxAware<List<LockData>, Object>()
+ {
+ public List<LockData> execute(Object arg) throws LockException
+ {
+ Set<Object> nodesId = cache.getChildrenNames(lockRoot);
+
+ List<LockData> locksData = new ArrayList<LockData>();
+ for (Object nodeId : nodesId)
+ {
+ LockData lockData = (LockData)cache.get(makeLockFqn((String)nodeId), LOCK_DATA);
+ if (lockData != null)
+ {
+ locksData.add(lockData);
+ }
+ }
+ return locksData;
+ }
+ };
}
/**
* If JDBC cache loader is used, then fills-in column types. If column type configured from jcr-configuration file,
* then nothing is overridden. Parameters are injected into the given parameterEntry.
*/
- public void configureJDBCCacheLoader(MappedParametrizedObjectEntry parameterEntry) throws RepositoryException
+ private void configureJDBCCacheLoader(MappedParametrizedObjectEntry parameterEntry) throws RepositoryException
{
String dataSourceName = parameterEntry.getParameterValue(JBOSSCACHE_JDBC_CL_DATASOURCE, null);
// if data source is defined, then inject correct data-types.
@@ -464,350 +446,10 @@
}
}
- @Managed
- @ManagedDescription("Remove the expired locks")
- public void cleanExpiredLocks()
- {
- removeExpired();
- }
-
- public long getDefaultLockTimeOut()
- {
- return lockTimeOut;
- }
-
- private final LockActionNonTxAware<Integer, Object> getNumLocks = new LockActionNonTxAware<Integer, Object>()
- {
- public Integer execute(Object arg)
- {
- return ((CacheSPI<Serializable, Object>)cache).getNumberOfNodes() - 1;
- }
- };
-
- @Managed
- @ManagedDescription("The number of active locks")
- public int getNumLocks()
- {
- try
- {
- return executeLockActionNonTxAware(getNumLocks, null);
- }
- catch (LockException e)
- {
- // ignore me will never occur
- }
- return -1;
- }
-
- private final LockActionNonTxAware<Boolean, Object> hasLocks = new LockActionNonTxAware<Boolean, Object>()
- {
- public Boolean execute(Object arg)
- {
- return ((CacheSPI<Serializable, Object>)cache).getNode(lockRoot).hasChildrenDirect();
- }
- };
-
/**
- * Indicates if some locks have already been created
- */
- private boolean hasLocks()
- {
- try
- {
- return executeLockActionNonTxAware(hasLocks, null);
- }
- catch (LockException e)
- {
- // ignore me will never occur
- }
- return true;
- }
-
- /**
- * Return new instance of session lock manager.
- */
- public SessionLockManager getSessionLockManager(String sessionId, SessionDataManager transientManager)
- {
- CacheableSessionLockManager sessionManager = new CacheableSessionLockManager(sessionId, this, transientManager);
- sessionLockManagers.put(sessionId, sessionManager);
- return sessionManager;
- }
-
- private final LockActionNonTxAware<Boolean, String> isLockLive = new LockActionNonTxAware<Boolean, String>()
- {
- public Boolean execute(String nodeId)
- {
- if (cache.get(makeLockFqn(nodeId), LOCK_DATA) != null) //pendingLocks.containsKey(nodeId) ||
- {
- return true;
- }
-
- return false;
- }
- };
-
- /**
- * Check is LockManager contains lock. No matter it is in pending or persistent state.
- *
- * @param nodeId - locked node id
- * @return
- */
- public boolean isLockLive(String nodeId) throws LockException
- {
- try
- {
- return executeLockActionNonTxAware(isLockLive, nodeId);
- }
- catch (LockException e)
- {
- // ignore me will never occur
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isTXAware()
- {
- return true;
- }
-
- /*
- * (non-Javadoc)
- * @seeorg.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener#onSaveItems(org.
- * exoplatform.services.jcr.dataflow.ItemStateChangesLog)
- */
- public void onSaveItems(ItemStateChangesLog changesLog)
- {
- List<PlainChangesLog> chengesLogList = new ArrayList<PlainChangesLog>();
- if (changesLog instanceof TransactionChangesLog)
- {
- ChangesLogIterator logIterator = ((TransactionChangesLog)changesLog).getLogIterator();
-
- while (logIterator.hasNextLog())
- {
- chengesLogList.add(logIterator.nextLog());
- }
- }
- else if (changesLog instanceof PlainChangesLog)
- {
- chengesLogList.add((PlainChangesLog)changesLog);
- }
- else if (changesLog instanceof CompositeChangesLog)
- {
- for (ChangesLogIterator iter = ((CompositeChangesLog)changesLog).getLogIterator(); iter.hasNextLog();)
- {
- chengesLogList.add(iter.nextLog());
- }
- }
-
- List<LockOperationContainer> containers = new ArrayList<LockOperationContainer>();
-
- for (PlainChangesLog currChangesLog : chengesLogList)
- {
- String sessionId = currChangesLog.getSessionId();
-
- String nodeIdentifier;
- try
- {
- switch (currChangesLog.getEventType())
- {
- case ExtendedEvent.LOCK :
- if (currChangesLog.getSize() < 2)
- {
- LOG.error("Incorrect changes log of type ExtendedEvent.LOCK size=" + currChangesLog.getSize()
- + "<2 \n" + currChangesLog.dump());
- break;
- }
- nodeIdentifier = currChangesLog.getAllStates().get(0).getData().getParentIdentifier();
-
- CacheableSessionLockManager session = sessionLockManagers.get(sessionId);
- if (session != null && session.containsPendingLock(nodeIdentifier))
- {
- containers.add(new LockOperationContainer(nodeIdentifier, currChangesLog.getSessionId(),
- ExtendedEvent.LOCK));
- }
- else
- {
- LOG.error("Lock must exist in pending locks.");
- }
- break;
- case ExtendedEvent.UNLOCK :
- if (currChangesLog.getSize() < 2)
- {
- LOG.error("Incorrect changes log of type ExtendedEvent.UNLOCK size=" + currChangesLog.getSize()
- + "<2 \n" + currChangesLog.dump());
- break;
- }
-
- containers.add(new LockOperationContainer(currChangesLog.getAllStates().get(0).getData()
- .getParentIdentifier(), currChangesLog.getSessionId(), ExtendedEvent.UNLOCK));
- break;
- default :
- HashSet<String> removedLock = new HashSet<String>();
- for (ItemState itemState : currChangesLog.getAllStates())
- {
- // this is a node and node is locked
- if (itemState.getData().isNode() && lockExist(itemState.getData().getIdentifier()))
- {
- nodeIdentifier = itemState.getData().getIdentifier();
- if (itemState.isDeleted())
- {
- removedLock.add(nodeIdentifier);
- }
- else if (itemState.isAdded() || itemState.isRenamed() || itemState.isUpdated())
- {
- removedLock.remove(nodeIdentifier);
- }
- }
- }
- for (String identifier : removedLock)
- {
- containers.add(new LockOperationContainer(identifier, currChangesLog.getSessionId(),
- ExtendedEvent.UNLOCK));
- }
- break;
- }
- }
- catch (IllegalStateException e)
- {
- LOG.error(e.getLocalizedMessage(), e);
- }
- }
-
- // sort locking and unlocking operations to avoid deadlocks in JBossCache
- Collections.sort(containers);
- for (LockOperationContainer container : containers)
- {
- try
- {
- container.apply();
- }
- catch (LockException e)
- {
- LOG.error(e.getMessage(), e);
- }
- }
- }
-
- /**
- * Class containing operation type (LOCK or UNLOCK) and all the needed information like node uuid and session id.
- */
- private class LockOperationContainer implements Comparable<LockOperationContainer>
- {
-
- private String identifier;
-
- private String sessionId;
-
- private int type;
-
- /**
- * @param identifier node identifier
- * @param sessionId id of session
- * @param type ExtendedEvent type specifying the operation (LOCK or UNLOCK)
- */
- public LockOperationContainer(String identifier, String sessionId, int type)
- {
- super();
- this.identifier = identifier;
- this.sessionId = sessionId;
- this.type = type;
- }
-
- /**
- * @return node identifier
- */
- public String getIdentifier()
- {
- return identifier;
- }
-
- public void apply() throws LockException
- {
- // invoke internalLock in LOCK operation
- if (type == ExtendedEvent.LOCK)
- {
- internalLock(sessionId, identifier);
- }
- // invoke internalUnLock in UNLOCK operation
- else if (type == ExtendedEvent.UNLOCK)
- {
- internalUnLock(sessionId, identifier);
- }
- }
-
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo(LockOperationContainer o)
- {
- return identifier.compareTo(o.getIdentifier());
- }
- }
-
- private final LockActionNonTxAware<Object, LockData> refresh = new LockActionNonTxAware<Object, LockData>()
- {
- public Object execute(LockData newLockData) throws LockException
- {
- Fqn<String> fqn = makeLockFqn(newLockData.getNodeIdentifier());
- Object oldValue = PrivilegedCacheHelper.put(cache, fqn, LOCK_DATA, newLockData);
- if (oldValue == null)
- {
- throw new LockException("Can't refresh lock for node " + newLockData.getNodeIdentifier()
- + " since lock is not exist");
- }
- return null;
- }
- };
-
- /**
- * Refreshed lock data in cache
- *
- * @param newLockData
- */
- public void refreshLockData(LockData newLockData) throws LockException
- {
- executeLockActionNonTxAware(refresh, newLockData);
- }
-
- /**
- * Remove expired locks. Used from LockRemover.
- */
- public synchronized void removeExpired()
- {
- final List<String> removeLockList = new ArrayList<String>();
-
- for (LockData lock : getLockList())
- {
- if (!lock.isSessionScoped() && lock.getTimeToDeath() < 0)
- {
- removeLockList.add(lock.getNodeIdentifier());
- }
- }
-
- Collections.sort(removeLockList);
-
- for (String rLock : removeLockList)
- {
- removeLock(rLock);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.picocontainer.Startable#start()
- */
- public void start()
- {
- lockRemover = new LockRemover(this);
- }
-
- /*
- * (non-Javadoc)
- * @see org.picocontainer.Startable#stop()
- */
+ * {@inheritDoc}
+ */
+ @Override
public void stop()
{
lockRemover.halt();
@@ -818,35 +460,11 @@
}
/**
- * Copy <code>PropertyData prop<code> to new TransientItemData
- *
- * @param prop
- * @return
- * @throws RepositoryException
+ * {@inheritDoc}
*/
- private TransientItemData copyItemData(PropertyData prop) throws RepositoryException
+ @Override
+ protected synchronized void internalLock(String sessionId, String nodeIdentifier) throws LockException
{
- if (prop == null)
- {
- return null;
- }
-
- // make a copy, value may be null for deleting items
- TransientPropertyData newData =
- new TransientPropertyData(prop.getQPath(), prop.getIdentifier(), prop.getPersistedVersion(), prop.getType(),
- prop.getParentIdentifier(), prop.isMultiValued(), prop.getValues());
-
- return newData;
- }
-
- /**
- * Internal lock
- *
- * @param nodeIdentifier
- * @throws LockException
- */
- private synchronized void internalLock(String sessionId, String nodeIdentifier) throws LockException
- {
CacheableSessionLockManager session = sessionLockManagers.get(sessionId);
if (session != null && session.containsPendingLock(nodeIdentifier))
{
@@ -874,13 +492,10 @@
}
/**
- * Internal unlock.
- *
- * @param sessionId
- * @param nodeIdentifier
- * @throws LockException
+ * {@inheritDoc}
*/
- private synchronized void internalUnLock(String sessionId, String nodeIdentifier) throws LockException
+ @Override
+ protected synchronized void internalUnLock(String sessionId, String nodeIdentifier) throws LockException
{
LockData lData = getLockDataById(nodeIdentifier);
@@ -896,256 +511,7 @@
}
}
- private final LockActionNonTxAware<Boolean, String> lockExist = new LockActionNonTxAware<Boolean, String>()
- {
- public Boolean execute(String nodeId) throws LockException
- {
- return cache.get(makeLockFqn(nodeId), LOCK_DATA) != null;
- }
- };
-
/**
- * {@inheritDoc}
- */
- public boolean lockExist(String nodeId)
- {
- try
- {
- return executeLockActionNonTxAware(lockExist, nodeId);
- }
- catch (LockException e)
- {
- // ignore me will never occur
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getLockTokenHash(String token)
- {
- String hash = "";
- try
- {
- MessageDigest m = MessageDigest.getInstance("MD5");
- m.update(token.getBytes(), 0, token.length());
- hash = new BigInteger(1, m.digest()).toString(16);
- }
- catch (NoSuchAlgorithmException e)
- {
- LOG.error("Can't get instanse of MD5 MessageDigest!", e);
- }
- return hash;
- }
-
- /**
- * {@inheritDoc}
- */
- public LockData getExactNodeOrCloseParentLock(NodeData node) throws RepositoryException
- {
- return getExactNodeOrCloseParentLock(node, true);
- }
-
- private LockData getExactNodeOrCloseParentLock(NodeData node, boolean checkHasLocks) throws RepositoryException
- {
-
- if (node == null || (checkHasLocks && !hasLocks()))
- {
- return null;
- }
- LockData retval = null;
- retval = getLockDataById(node.getIdentifier());
- if (retval == null)
- {
- NodeData parentData = (NodeData)dataManager.getItemData(node.getParentIdentifier());
- if (parentData != null)
- {
- retval = getExactNodeOrCloseParentLock(parentData, false);
- }
- }
- return retval;
- }
-
- /**
- * {@inheritDoc}
- */
- public LockData getExactNodeLock(NodeData node) throws RepositoryException
- {
- if (node == null || !hasLocks())
- {
- return null;
- }
-
- return getLockDataById(node.getIdentifier());
- }
-
- /**
- * {@inheritDoc}
- */
- public LockData getClosedChild(NodeData node) throws RepositoryException
- {
- return getClosedChild(node, true);
- }
-
- private LockData getClosedChild(NodeData node, boolean checkHasLocks) throws RepositoryException
- {
-
- if (node == null || (checkHasLocks && !hasLocks()))
- {
- return null;
- }
- LockData retval = null;
-
- List<NodeData> childData = dataManager.getChildNodesData(node);
- for (NodeData nodeData : childData)
- {
- retval = getLockDataById(nodeData.getIdentifier());
- if (retval != null)
- return retval;
- }
- // child not found try to find dipper
- for (NodeData nodeData : childData)
- {
- retval = getClosedChild(nodeData, false);
- if (retval != null)
- return retval;
- }
- return retval;
- }
-
- private final LockActionNonTxAware<LockData, String> getLockDataById = new LockActionNonTxAware<LockData, String>()
- {
- public LockData execute(String nodeId) throws LockException
- {
- return (LockData)cache.get(makeLockFqn(nodeId), LOCK_DATA);
- }
- };
-
- protected LockData getLockDataById(String nodeId)
- {
- try
- {
- return executeLockActionNonTxAware(getLockDataById, nodeId);
- }
- catch (LockException e)
- {
- // ignore me will never occur
- }
- return null;
- }
-
- private final LockActionNonTxAware<List<LockData>, Object> getLockList =
- new LockActionNonTxAware<List<LockData>, Object>()
- {
- public List<LockData> execute(Object arg) throws LockException
- {
- Set<Object> nodesId = cache.getChildrenNames(lockRoot);
-
- List<LockData> locksData = new ArrayList<LockData>();
- for (Object nodeId : nodesId)
- {
- LockData lockData = (LockData)cache.get(makeLockFqn((String)nodeId), LOCK_DATA);
- if (lockData != null)
- {
- locksData.add(lockData);
- }
- }
- return locksData;
- }
- };
-
- protected synchronized List<LockData> getLockList()
- {
- try
- {
- return executeLockActionNonTxAware(getLockList, null);
- }
- catch (LockException e)
- {
- // ignore me will never occur
- }
- return null;
- }
-
- /**
- * Remove lock, used by Lock remover.
- *
- * @param nodeIdentifier String
- */
- protected void removeLock(String nodeIdentifier)
- {
- try
- {
- NodeData nData = (NodeData)dataManager.getItemData(nodeIdentifier);
-
- //TODO EXOJCR-412, should be refactored in future.
- //Skip removing, because that node was removed in other node of cluster.
- if (nData == null)
- {
- return;
- }
-
- PlainChangesLog changesLog =
- new PlainChangesLogImpl(new ArrayList<ItemState>(), SystemIdentity.SYSTEM, ExtendedEvent.UNLOCK);
-
- ItemData lockOwner =
- copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKOWNER, 1)));
-
- //TODO EXOJCR-412, should be refactored in future.
- //Skip removing, because that lock was removed in other node of cluster.
- if (lockOwner == null)
- {
- return;
- }
-
- changesLog.add(ItemState.createDeletedState(lockOwner));
-
- ItemData lockIsDeep =
- copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKISDEEP, 1)));
-
- //TODO EXOJCR-412, should be refactored in future.
- //Skip removing, because that lock was removed in other node of cluster.
- if (lockIsDeep == null)
- {
- return;
- }
-
- changesLog.add(ItemState.createDeletedState(lockIsDeep));
-
- // lock probably removed by other thread
- if (lockOwner == null && lockIsDeep == null)
- {
- return;
- }
-
- dataManager.save(new TransactionChangesLog(changesLog));
- }
- catch (JCRInvalidItemStateException e)
- {
- //TODO EXOJCR-412, should be refactored in future.
- //Skip property not found in DB, because that lock property was removed in other node of cluster.
- if (LOG.isDebugEnabled())
- {
- LOG.debug("The propperty was removed in other node of cluster.", e);
- }
-
- }
- catch (RepositoryException e)
- {
- LOG.error("Error occur during removing lock" + e.getLocalizedMessage(), e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void closeSessionLockManager(String sessionID)
- {
- sessionLockManagers.remove(sessionID);
- }
-
- /**
* Make lock absolute Fqn, i.e. /$LOCKS/nodeID.
*
* @param itemId String
@@ -1169,57 +535,4 @@
}
node.setResident(true);
}
-
- /**
- * Execute the given action outside a transaction. This is needed since the {@link Cache} used by {@link CacheableLockManagerImpl}
- * manages the persistence of its locks thanks to a {@link CacheLoader} and a {@link CacheLoader} lock the JBoss cache {@link Node}
- * even for read operations which cause deadlock issue when a XA {@link Transaction} is already opened
- * @throws LockException when a exception occurs
- */
- private <R, A> R executeLockActionNonTxAware(LockActionNonTxAware<R, A> action, A arg) throws LockException
- {
- Transaction tx = null;
- try
- {
- if (tm != null)
- {
- try
- {
- tx = tm.suspend();
- }
- catch (Exception e)
- {
- LOG.warn("Cannot suspend the current transaction", e);
- }
- }
- return action.execute(arg);
- }
- finally
- {
- if (tx != null)
- {
- try
- {
- tm.resume(tx);
- }
- catch (Exception e)
- {
- LOG.warn("Cannot resume the current transaction", e);
- }
- }
- }
- }
-
- /**
- * Actions that are not supposed to be called within a transaction
- *
- * Created by The eXo Platform SAS
- * Author : Nicolas Filotto
- * nicolas.filotto(a)exoplatform.com
- * 21 janv. 2010
- */
- private static interface LockActionNonTxAware<R, A>
- {
- R execute(A arg) throws LockException;
- }
}
Modified: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedCacheHelper.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedCacheHelper.java 2010-08-30 06:26:51 UTC (rev 3000)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedCacheHelper.java 2010-08-30 06:56:05 UTC (rev 3001)
@@ -164,114 +164,4 @@
}
}
- /**
- * Start Infinispan cache in privileged mode.
- *
- * @param cache
- */
- public static void start(final org.infinispan.Cache<Serializable, Object> cache)
- {
- PrivilegedAction<Object> action = new PrivilegedAction<Object>()
- {
- public Object run()
- {
- cache.start();
- return null;
- }
- };
- AccessController.doPrivileged(action);
- }
-
- /**
- * Stop Infinispan cache in privileged mode.
- *
- * @param cache
- */
- public static void stop(final org.infinispan.Cache<Serializable, Object> cache)
- {
- PrivilegedAction<Object> action = new PrivilegedAction<Object>()
- {
- public Object run()
- {
- cache.stop();
- return null;
- }
- };
- AccessController.doPrivileged(action);
- }
-
- /**
- * Put in Infinispan cache in privileged mode.
- *
- * @param cache
- */
- public static Object putIfAbsent(final org.infinispan.Cache<Serializable, Object> cache, final Serializable key,
- final Object value) throws CacheException
- {
- PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
- {
- public Object run() throws Exception
- {
- return cache.putIfAbsent(key, value);
- }
- };
- try
- {
- return AccessController.doPrivileged(action);
- }
- catch (PrivilegedActionException pae)
- {
- Throwable cause = pae.getCause();
- if (cause instanceof CacheException)
- {
- throw (CacheException)cause;
- }
- else if (cause instanceof RuntimeException)
- {
- throw (RuntimeException)cause;
- }
- else
- {
- throw new RuntimeException(cause);
- }
- }
- }
-
- /**
- * Put in Infinispan cache in privileged mode.
- *
- * @param cache
- */
- public static Object put(final org.infinispan.Cache<Serializable, Object> cache, final Serializable key,
- final Object value) throws CacheException
- {
- PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
- {
- public Object run() throws Exception
- {
- return cache.put(key, value);
- }
- };
- try
- {
- return AccessController.doPrivileged(action);
- }
- catch (PrivilegedActionException pae)
- {
- Throwable cause = pae.getCause();
- if (cause instanceof CacheException)
- {
- throw (CacheException)cause;
- }
- else if (cause instanceof RuntimeException)
- {
- throw (RuntimeException)cause;
- }
- else
- {
- throw new RuntimeException(cause);
- }
- }
- }
-
}
Added: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedISPNCacheHelper.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedISPNCacheHelper.java (rev 0)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedISPNCacheHelper.java 2010-08-30 06:56:05 UTC (rev 3001)
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2010 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.jcr.impl.util.io;
+
+import org.infinispan.Cache;
+
+import java.io.Serializable;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
+ * @version $Id: PrivilegedCacheHelper.java 111 2010-11-11 11:11:11Z tolusha $
+ *
+ */
+public class PrivilegedISPNCacheHelper
+{
+
+ /**
+ * Start Infinispan cache in privileged mode.
+ *
+ * @param cache
+ */
+ public static void start(final org.infinispan.Cache<Serializable, Object> cache)
+ {
+ PrivilegedAction<Object> action = new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ cache.start();
+ return null;
+ }
+ };
+ AccessController.doPrivileged(action);
+ }
+
+ /**
+ * Stop Infinispan cache in privileged mode.
+ *
+ * @param cache
+ */
+ public static void stop(final Cache<Serializable, Object> cache)
+ {
+ PrivilegedAction<Object> action = new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ cache.stop();
+ return null;
+ }
+ };
+ AccessController.doPrivileged(action);
+ }
+
+ /**
+ * Put in Infinispan cache in privileged mode.
+ *
+ * @param cache
+ */
+ public static Object putIfAbsent(final Cache<Serializable, Object> cache, final Serializable key, final Object value)
+ {
+ PrivilegedAction<Object> action = new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ return cache.putIfAbsent(key, value);
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
+
+ /**
+ * Put in Infinispan cache in privileged mode.
+ *
+ * @param cache
+ */
+ public static Object put(final Cache<Serializable, Object> cache, final Serializable key, final Object value)
+ {
+ PrivilegedAction<Object> action = new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ return cache.put(key, value);
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
+
+}
Added: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheHelper.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheHelper.java (rev 0)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheHelper.java 2010-08-30 06:56:05 UTC (rev 3001)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2010 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.jcr.infinispan;
+
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.services.jcr.config.TemplateConfigurationHelper;
+
+/**
+ * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
+ * @version $Id: ISPNCacheHelper.java 111 2010-11-11 11:11:11Z tolusha $
+ *
+ */
+public class ISPNCacheHelper extends TemplateConfigurationHelper
+{
+
+ /**
+ * Creates configuration cache helper with pre-configured for Infinispan cache parameters,<br>
+ * including: "infinispan-*" and "jgroups-configuration", and excluding "infinispan-configuration"
+ *
+ * @param cfm
+ * instance for looking up resources
+ */
+ public ISPNCacheHelper(ConfigurationManager cfm)
+ {
+ super(new String[]{"^jgroups-configuration", "^infinispan-.*"}, new String[]{"^infinispan-configuration"}, cfm);
+ }
+}
Modified: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/InfinispanCacheFactory.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/InfinispanCacheFactory.java 2010-08-30 06:26:51 UTC (rev 3000)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/InfinispanCacheFactory.java 2010-08-30 06:56:05 UTC (rev 3001)
@@ -62,7 +62,7 @@
*/
public InfinispanCacheFactory(ConfigurationManager configurationManager)
{
- this.configurationHelper = TemplateConfigurationHelper.createJBossCacheHelper(configurationManager);
+ this.configurationHelper = new ISPNCacheHelper(configurationManager);
}
/**
Modified: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/ExoJBossCacheFactory.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/ExoJBossCacheFactory.java 2010-08-30 06:26:51 UTC (rev 3000)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/ExoJBossCacheFactory.java 2010-08-30 06:56:05 UTC (rev 3001)
@@ -78,7 +78,7 @@
public ExoJBossCacheFactory(ConfigurationManager configurationManager, TransactionManager transactionManager)
{
this.configurationManager = configurationManager;
- this.configurationHelper = TemplateConfigurationHelper.createJBossCacheHelper(configurationManager);
+ this.configurationHelper = new JBossCacheHelper(configurationManager);
this.transactionManager = transactionManager;
}
Added: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/JBossCacheHelper.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/JBossCacheHelper.java (rev 0)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/JBossCacheHelper.java 2010-08-30 06:56:05 UTC (rev 3001)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2010 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.jcr.jbosscache;
+
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.services.jcr.config.TemplateConfigurationHelper;
+
+/**
+ * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
+ * @version $Id: ISPNCacheHelper.java 111 2010-11-11 11:11:11Z tolusha $
+ *
+ */
+public class JBossCacheHelper extends TemplateConfigurationHelper
+{
+
+ /**
+ * Creates configuration cache helper with pre-configured for JBossCache parameters,<br>
+ * including: "jbosscache-*" and "jgroups-configuration", and excluding "jbosscache-configuration"
+ *
+ * @param cfm
+ * instance for looking up resources
+ */
+ public JBossCacheHelper(ConfigurationManager cfm)
+ {
+ super(new String[]{"^jbosscache-.*", "^jgroups-configuration"}, new String[]{"^jbosscache-configuration"}, cfm);
+ }
+}
Modified: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/config/TestTemplateConfigurationHelper.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/config/TestTemplateConfigurationHelper.java 2010-08-30 06:26:51 UTC (rev 3000)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/config/TestTemplateConfigurationHelper.java 2010-08-30 06:56:05 UTC (rev 3001)
@@ -18,10 +18,11 @@
*/
package org.exoplatform.services.jcr.config;
+import junit.framework.TestCase;
+
import org.exoplatform.container.configuration.ConfigurationManagerImpl;
+import org.exoplatform.services.jcr.jbosscache.JBossCacheHelper;
-import junit.framework.TestCase;
-
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -39,8 +40,7 @@
public void testFilters()
{
// create helper with predefined include and exclude patterns
- TemplateConfigurationHelper helper =
- TemplateConfigurationHelper.createJBossCacheHelper(new ConfigurationManagerImpl());
+ TemplateConfigurationHelper helper = new JBossCacheHelper(new ConfigurationManagerImpl());
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("jbosscache-configuration", "");
parameters.put("jbosscache-cache.loader", "");
@@ -58,7 +58,7 @@
public void testFilters2()
{
// create helper with predefined include and exclude patterns
- TemplateConfigurationHelper helper = TemplateConfigurationHelper.createJBossCacheHelper(new ConfigurationManagerImpl());
+ TemplateConfigurationHelper helper = new JBossCacheHelper(new ConfigurationManagerImpl());
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("jgroups-configuration", "");
parameters.put("jbosscache-cache.loader", "");
@@ -74,7 +74,7 @@
public void testTemplating() throws IOException
{
- TemplateConfigurationHelper helper = TemplateConfigurationHelper.createJBossCacheHelper(new ConfigurationManagerImpl());
+ TemplateConfigurationHelper helper = new JBossCacheHelper(new ConfigurationManagerImpl());
String template = "configuration in any format, containing ${jbosscache-template-variable} and many others";
String expectedConfig = "configuration in any format, containing pretty good parameter and many others";
13 years, 10 months
exo-jcr SVN: r3000 - in jcr/branches/1.12.x/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/xml/importing/dataflow and 1 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-08-30 02:26:51 -0400 (Mon, 30 Aug 2010)
New Revision: 3000
Added:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/NodePropertiesInfo.java
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/SystemViewImporter.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/dataflow/ImportPropertyData.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java
Log:
EXOJCR-880 : Determine if property is multi or single value from nodetype definition in import was implemented.
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 2010-08-27 14:50:10 UTC (rev 2999)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/DocumentViewImporter.java 2010-08-30 06:26:51 UTC (rev 3000)
@@ -36,6 +36,7 @@
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.core.JCRName;
import org.exoplatform.services.jcr.impl.core.LocationFactory;
import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
import org.exoplatform.services.jcr.impl.core.value.BaseValue;
@@ -344,19 +345,41 @@
// determinating is property multivalue;
if (values.size() == 1)
{
- // there is single-value defeniton
- if (defs.getDefinition(false) != null)
+ PropertyDefinitionDatas vhdefs = null;
+
+ if (defs.getAnyDefinition().isResidualSet())
{
- if (defs.getDefinition(false).isResidualSet() && nodeData.getPrimaryTypeName().equals(Constants.NT_FROZENNODE)
- && propName.equals(Constants.JCR_PREDECESSORS))
+ if (nodeData.getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH))
{
- /// TODO EXOJCR-865
- isMultivalue = true;
+ if (nodeData.getPrimaryTypeName().equals(Constants.NT_FROZENNODE))
+ {
+ // get primaryType
+ InternalQName fptName = locationFactory.parseJCRName(atts.get("jcr:frozenPrimaryType")).getInternalName();
+
+ // get mixin types
+ List<JCRName> mtNames = getJCRNames(atts.get("jcr:frozenMixinTypes"));
+
+ InternalQName fmtName[] = new InternalQName[mtNames.size()];
+
+ for (int i = 0; i < mtNames.size(); i++)
+ {
+ fmtName[i] = new InternalQName(mtNames.get(i).getNamespace(), mtNames.get(i).getName());
+ }
+
+ vhdefs = nodeTypeDataManager.getPropertyDefinitions(propName, fptName, fmtName);
+
+ if (vhdefs != null)
+ {
+ isMultivalue = (vhdefs.getDefinition(true) != null ? true : false);
+ }
+ }
}
- else
- {
+ }
+
+ // there is single-value defeniton
+ if (vhdefs == null && defs.getDefinition(false) != null)
+ {
isMultivalue = false;
- }
}
}
else
@@ -396,6 +419,28 @@
createVersionHistory(nodeData);
}
}
+
+ private List<JCRName> getJCRNames(String string) throws RepositoryException
+ {
+ List<JCRName> mtNames = new ArrayList<JCRName>();
+
+ StringTokenizer spaceToken = new StringTokenizer(string);
+
+ List<String> denormalizedStrings = new ArrayList<String>();
+ while (spaceToken.hasMoreTokens())
+ {
+ String elem = spaceToken.nextToken();
+ String denormalizeString = StringConverter.denormalizeString(elem);
+ denormalizedStrings.add(denormalizeString);
+ }
+
+ for (String mixinName : denormalizedStrings)
+ {
+ mtNames.add(locationFactory.parseJCRName(mixinName));
+ }
+
+ return mtNames;
+ }
private ImportNodeData createNode(List<NodeTypeData> nodeTypes, HashMap<InternalQName, String> propertiesMap,
List<InternalQName> mixinNodeTypes, InternalQName jcrName) throws PathNotFoundException, IllegalPathException,
Added: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/NodePropertiesInfo.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/NodePropertiesInfo.java (rev 0)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/NodePropertiesInfo.java 2010-08-30 06:26:51 UTC (rev 3000)
@@ -0,0 +1,60 @@
+/*
+ * 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.xml.importing;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.exoplatform.services.jcr.impl.xml.importing.dataflow.ImportNodeData;
+import org.exoplatform.services.jcr.impl.xml.importing.dataflow.ImportPropertyData;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2010
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id: NodePropertiesInfo.java 2990 2010-08-26 07:24:28Z areshetnyak $
+ */
+public class NodePropertiesInfo
+{
+
+ private final ImportNodeData node;
+
+ private final List<ImportPropertyData> properties = new ArrayList<ImportPropertyData>();
+
+ public NodePropertiesInfo(ImportNodeData newNodeData)
+ {
+ this.node = newNodeData;
+ }
+
+ public void addProperty(ImportPropertyData propertyData)
+ {
+ properties.add(propertyData);
+ }
+
+ public ImportNodeData getNode()
+ {
+ return node;
+ }
+
+ public List<ImportPropertyData> getProperties()
+ {
+ return properties;
+ }
+
+}
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 2010-08-27 14:50:10 UTC (rev 2999)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/SystemViewImporter.java 2010-08-30 06:26:51 UTC (rev 3000)
@@ -18,12 +18,28 @@
*/
package org.exoplatform.services.jcr.impl.xml.importing;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+
import org.exoplatform.services.jcr.access.AccessManager;
import org.exoplatform.services.jcr.core.ExtendedPropertyType;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionDatas;
import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.dataflow.ItemState;
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.IllegalPathException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.NodeData;
@@ -46,20 +62,6 @@
import org.exoplatform.services.log.Log;
import org.exoplatform.services.security.ConversationState;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.NamespaceRegistry;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.ValueFormatException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-
/**
* Created by The eXo Platform SAS.
*
@@ -74,6 +76,8 @@
private static Log log = ExoLogger.getLogger("exo.jcr.component.core.SystemViewImporter");
protected PropertyInfo propertyInfo = new PropertyInfo();
+
+ protected Map<String, NodePropertiesInfo> mapNodePropertiesInfo = new HashMap<String, NodePropertiesInfo>();
/**
* Root node name.
@@ -150,7 +154,15 @@
ImportPropertyData propertyData = endProperty();
if (propertyData != null)
+ {
changesLog.add(new ItemState(propertyData, ItemState.ADDED, true, getAncestorToSave()));
+
+ ImportNodeData currentNodeInfo = (ImportNodeData)getParent();
+
+ NodePropertiesInfo currentNodePropertiesInfo = mapNodePropertiesInfo.get(currentNodeInfo.getQPath().getAsString());
+
+ currentNodePropertiesInfo.addProperty(propertyData);
+ }
}
else if (Constants.SV_VALUE_NAME.equals(elementName))
{
@@ -206,6 +218,8 @@
newNodeData.setIdentifier(IdGenerator.generate());
changesLog.add(new ItemState(newNodeData, ItemState.ADDED, true, getAncestorToSave()));
+
+ mapNodePropertiesInfo.put(newNodeData.getQPath().getAsString(), new NodePropertiesInfo(newNodeData));
tree.push(newNodeData);
@@ -293,6 +307,15 @@
{
ImportNodeData currentNodeInfo = (ImportNodeData)tree.pop();
+ NodePropertiesInfo currentNodePropertiesInfo = mapNodePropertiesInfo.get(currentNodeInfo.getQPath().getAsString());
+
+ if (currentNodePropertiesInfo != null)
+ {
+ checkPropertis(currentNodePropertiesInfo);
+ }
+
+ mapNodePropertiesInfo.remove(currentNodeInfo.getQPath().getAsString());
+
currentNodeInfo.setMixinTypeNames(currentNodeInfo.getMixinTypeNames());
if (currentNodeInfo.isMixVersionable())
@@ -303,7 +326,84 @@
currentNodeInfo.setACL(initAcl(currentNodeInfo.getACL(), currentNodeInfo.isExoOwneable(), currentNodeInfo
.isExoPrivilegeable(), currentNodeInfo.getExoOwner(), currentNodeInfo.getExoPrivileges()));
}
+
+ /**
+ * Checking priopertis if nodetype is nt:frozennode
+ *
+ * @param currentNodePropertiesInfo
+ * @throws RepositoryException
+ * @throws IOException
+ * @throws IllegalNameException
+ * @throws IllegalStateException
+ */
+ private void checkPropertis(NodePropertiesInfo currentNodePropertiesInfo) throws RepositoryException
+ {
+ if (currentNodePropertiesInfo.getNode().getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH)
+ && currentNodePropertiesInfo.getNode().getPrimaryTypeName().equals(Constants.NT_FROZENNODE))
+ {
+ // name of frozenPrimaryType property
+ InternalQName fptPropertyName = locationFactory.parseJCRName("jcr:frozenPrimaryType").getInternalName();
+ // node of frozenMixinTypes property
+ InternalQName fmtPropertyName = locationFactory.parseJCRName("jcr:frozenMixinTypes").getInternalName();
+
+ InternalQName fptName = null;
+ List<InternalQName> fmtNames = new ArrayList<InternalQName>();
+
+ // get frozenPrimaryType and frozenMixinTypes
+ try
+ {
+ for (ImportPropertyData propertyData : currentNodePropertiesInfo.getProperties())
+ {
+ if (propertyData.getQName().equals(fptPropertyName))
+ {
+ fptName = InternalQName.parse(new String(propertyData.getValues().get(0).getAsByteArray()));
+ }
+ else if (propertyData.getQName().equals(fmtPropertyName))
+ {
+ for (ValueData valueData : propertyData.getValues())
+ {
+ fmtNames.add(InternalQName.parse(new String(valueData.getAsByteArray())));
+ }
+ }
+ }
+ }
+ catch (IllegalStateException e)
+ {
+ throw new RepositoryException(e.getMessage(), e);
+ }
+ catch (IllegalNameException e)
+ {
+ throw new RepositoryException(e.getMessage(), e);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e.getMessage(), e);
+ }
+
+ InternalQName nodePrimaryTypeName = currentNodePropertiesInfo.getNode().getPrimaryTypeName();
+ InternalQName[] nodeMixinTypeName = currentNodePropertiesInfo.getNode().getMixinTypeNames();
+
+ for (ImportPropertyData propertyData : currentNodePropertiesInfo.getProperties())
+ {
+ PropertyDefinitionDatas defs = nodeTypeDataManager.getPropertyDefinitions(propertyData.getQName(), nodePrimaryTypeName, nodeMixinTypeName);
+
+ if (defs == null || (defs != null && defs.getAnyDefinition().isResidualSet()))
+ {
+ PropertyDefinitionDatas vhdefs =
+ nodeTypeDataManager.getPropertyDefinitions(propertyData.getQName(), fptName, fmtNames
+ .toArray(new InternalQName[fmtNames.size()]));
+
+ if (vhdefs != null)
+ {
+ boolean isMultivalue = (vhdefs.getDefinition(true) != null ? true : false);
+ propertyData.setMultivalue(isMultivalue);
+ }
+ }
+ }
+ }
+ }
+
/**
* endPrimaryType.
*
@@ -414,16 +514,7 @@
// there is single-value defeniton
if (defs.getDefinition(false) != null)
{
- if (defs.getDefinition(false).isResidualSet() && currentNodeInfo.getPrimaryTypeName().equals(Constants.NT_FROZENNODE)
- && propertyInfo.getName().equals(Constants.JCR_PREDECESSORS))
- {
- /// TODO EXOJCR-865
- isMultivalue = true;
- }
- else
- {
- isMultivalue = false;
- }
+ isMultivalue = false;
}
}
else
@@ -481,6 +572,9 @@
}
tree.push(currentNodeInfo);
+
+ mapNodePropertiesInfo.put(currentNodeInfo.getQPath().getAsString(), new NodePropertiesInfo(currentNodeInfo));
+
return propertyData;
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/dataflow/ImportPropertyData.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/dataflow/ImportPropertyData.java 2010-08-27 14:50:10 UTC (rev 2999)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/dataflow/ImportPropertyData.java 2010-08-30 06:26:51 UTC (rev 3000)
@@ -80,8 +80,21 @@
{
this.parentIdentifier = identifer;
}
+
+ /**
+ * Set multiValued;
+ *
+ * @param multiValue
+ * - multi value
+ */
+ public void setMultivalue(boolean multiValue)
+ {
+ this.multiValued = multiValue;
+ }
/**
+
+ /**
* Set path of item.
*
* @param path
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java 2010-08-27 14:50:10 UTC (rev 2999)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java 2010-08-30 06:26:51 UTC (rev 3000)
@@ -557,7 +557,7 @@
byte[] versionableNode = serialize(fileNode, false, true);
// version history
byte[] versionHistory = serialize(fileNode.getVersionHistory(), false, true);
- System.out.println(new String(versionHistory));
+ // System.out.println(new String(versionHistory));
fileNode.remove();
session.save();
assertFalse(testRoot.hasNode("TestJCR1247"));
@@ -1046,7 +1046,7 @@
byte[] versionableNode = serialize(fileNode, false, true);
// version history
byte[] versionHistory = serialize(fileNode.getVersionHistory(), false, true);
- System.out.println(new String(versionHistory));
+ // System.out.println(new String(versionHistory));
@@ -1129,11 +1129,9 @@
// node content
byte[] versionableNode = serialize(fileNode, true, true);
// version history
- byte[] versionHistory = serialize(fileNode.getVersionHistory(), false, true);
- System.out.println(new String(versionHistory));
-
+ byte[] versionHistory = serialize(fileNode.getVersionHistory(), true, true);
+ //System.out.println(new String(versionHistory));
-
// restore node content
Node restoreRoot = testRoot.addNode("restRoot");
testRoot.save();
@@ -1367,7 +1365,7 @@
byte[] versionableNode = serialize(web, false, true);
// version history
byte[] versionHistory = serialize(web.getVersionHistory(), false, true);
- System.out.println(new String(versionHistory));
+ // System.out.println(new String(versionHistory));
// restore node content
@@ -1604,7 +1602,7 @@
byte[] versionableNode = serialize(web, true, true);
// version history
byte[] versionHistory = serialize(web.getVersionHistory(), true, true);
- System.out.println(new String(versionHistory));
+ // System.out.println(new String(versionHistory));
// restore node content
@@ -1684,7 +1682,7 @@
byte[] versionableNode = serialize(web, false, true);
// version history
byte[] versionHistory = serialize(web.getVersionHistory(), false, true);
- System.out.println(new String(versionHistory));
+ // System.out.println(new String(versionHistory));
// restore node content
@@ -1764,7 +1762,7 @@
byte[] versionableNode = serialize(web, true, true);
// version history
byte[] versionHistory = serialize(web.getVersionHistory(), true, true);
- System.out.println(new String(versionHistory));
+ // System.out.println(new String(versionHistory));
// restore node content
Node restoreRoot = testRoot.addNode("restRootWeb");
@@ -1802,4 +1800,194 @@
fileImport.checkout();
root.save();
}
+
+ /**
+ * https://jira.jboss.org/browse/EXOJCR-865
+ *
+ * @throws Exception
+ */
+ public void testEXOJCR865_Doc_exo_links() throws Exception
+ {
+
+ Node testRoot = root.addNode("testRoot");
+ Node fileNode = testRoot.addNode("TestEXOJCR865_exo_links", "nt:file");
+ Node contentNode = fileNode.addNode("jcr:content", "nt:resource");
+ contentNode.setProperty("jcr:data", new ByteArrayInputStream("".getBytes()));
+ contentNode.setProperty("jcr:mimeType", "image/jpg");
+ contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
+ root.save();
+ Node contentNodeBeforeAddVersion = fileNode.getNode("jcr:content");
+ assertNotNull(contentNodeBeforeAddVersion.getProperty("jcr:lastModified"));
+ if (fileNode.canAddMixin("mix:versionable"))
+ {
+ fileNode.addMixin("mix:versionable");
+ }
+
+ fileNode.addMixin("exo:linkable");
+
+ fileNode.setProperty("exo:links", new String[] {"1"});
+
+ fileNode.save();
+ fileNode.checkin();
+ fileNode.checkout();
+ root.save();
+
+ fileNode.checkin();
+ fileNode.checkout();
+ root.save();
+
+ fileNode.checkin();
+ fileNode.checkout();
+ root.save();
+
+ String nodeDump = dumpVersionable(fileNode);
+ // Export VersionHistory
+
+ assertTrue(fileNode.isNodeType("mix:versionable"));
+
+ VersionableNodeInfo nodeInfo = new VersionableNodeInfo(fileNode);
+
+ // node content
+ byte[] versionableNode = serialize(fileNode, false, true);
+ // version history
+ byte[] versionHistory = serialize(fileNode.getVersionHistory(), false, true);
+ //System.out.println(new String(versionHistory));
+
+ // restore node content
+ Node restoreRoot = testRoot.addNode("restRoot");
+ testRoot.save();
+
+ deserialize(restoreRoot, XmlSaveType.SESSION, true, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING,
+ new ByteArrayInputStream(versionableNode));
+ root.save();
+
+ assertTrue(restoreRoot.hasNode("TestEXOJCR865_exo_links"));
+
+ Node fileImport = restoreRoot.getNode("TestEXOJCR865_exo_links");
+ assertTrue(fileImport.isNodeType("mix:versionable"));
+
+ VersionHistoryImporter versionHistoryImporter =
+ new VersionHistoryImporter((NodeImpl)fileImport, new ByteArrayInputStream(versionHistory), nodeInfo
+ .getBaseVersion(), nodeInfo.getPredecessorsHistory(), nodeInfo.getVersionHistory());
+ versionHistoryImporter.doImport();
+ root.save();
+
+ Property property = fileImport.getProperty("exo:links");
+ assertNotNull(property);
+ assertNotNull(property.getDefinition());
+
+ property = fileImport.getProperty("jcr:predecessors");
+ assertNotNull(property);
+ assertNotNull(property.getDefinition());
+
+ fileImport.restore("2", true);
+ root.save();
+
+ property = fileImport.getProperty("exo:links");
+ assertNotNull(property);
+ assertNotNull(property.getDefinition());
+
+ property = fileImport.getProperty("jcr:predecessors");
+ assertNotNull(property);
+ assertNotNull(property.getDefinition());
+
+ fileImport.checkin();
+ fileImport.checkout();
+ root.save();
+ }
+
+ /**
+ * https://jira.jboss.org/browse/EXOJCR-865
+ *
+ * @throws Exception
+ */
+ public void testEXOJCR865_Sys_exo_links() throws Exception
+ {
+
+ Node testRoot = root.addNode("testRoot");
+ Node fileNode = testRoot.addNode("TestEXOJCR865_exo_links", "nt:file");
+ Node contentNode = fileNode.addNode("jcr:content", "nt:resource");
+ contentNode.setProperty("jcr:data", new ByteArrayInputStream("".getBytes()));
+ contentNode.setProperty("jcr:mimeType", "image/jpg");
+ contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
+ root.save();
+ Node contentNodeBeforeAddVersion = fileNode.getNode("jcr:content");
+ assertNotNull(contentNodeBeforeAddVersion.getProperty("jcr:lastModified"));
+ if (fileNode.canAddMixin("mix:versionable"))
+ {
+ fileNode.addMixin("mix:versionable");
+ }
+
+ fileNode.addMixin("exo:linkable");
+
+ fileNode.setProperty("exo:links", new String[] {"1"});
+
+ fileNode.save();
+ fileNode.checkin();
+ fileNode.checkout();
+ root.save();
+
+ fileNode.checkin();
+ fileNode.checkout();
+ root.save();
+
+ fileNode.checkin();
+ fileNode.checkout();
+ root.save();
+
+ String nodeDump = dumpVersionable(fileNode);
+ // Export VersionHistory
+
+ assertTrue(fileNode.isNodeType("mix:versionable"));
+
+ VersionableNodeInfo nodeInfo = new VersionableNodeInfo(fileNode);
+
+ // node content
+ byte[] versionableNode = serialize(fileNode, true, true);
+ // version history
+ byte[] versionHistory = serialize(fileNode.getVersionHistory(), true, true);
+ //System.out.println(new String(versionHistory));
+
+ // restore node content
+ Node restoreRoot = testRoot.addNode("restRoot");
+ testRoot.save();
+
+ deserialize(restoreRoot, XmlSaveType.SESSION, true, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING,
+ new ByteArrayInputStream(versionableNode));
+ root.save();
+
+ assertTrue(restoreRoot.hasNode("TestEXOJCR865_exo_links"));
+
+ Node fileImport = restoreRoot.getNode("TestEXOJCR865_exo_links");
+ assertTrue(fileImport.isNodeType("mix:versionable"));
+
+ VersionHistoryImporter versionHistoryImporter =
+ new VersionHistoryImporter((NodeImpl)fileImport, new ByteArrayInputStream(versionHistory), nodeInfo
+ .getBaseVersion(), nodeInfo.getPredecessorsHistory(), nodeInfo.getVersionHistory());
+ versionHistoryImporter.doImport();
+ root.save();
+
+ Property property = fileImport.getProperty("exo:links");
+ assertNotNull(property);
+ assertNotNull(property.getDefinition());
+
+ property = fileImport.getProperty("jcr:predecessors");
+ assertNotNull(property);
+ assertNotNull(property.getDefinition());
+
+ fileImport.restore("2", true);
+ root.save();
+
+ property = fileImport.getProperty("jcr:predecessors");
+ assertNotNull(property);
+ assertNotNull(property.getDefinition());
+
+ property = fileImport.getProperty("exo:links");
+ assertNotNull(property);
+ assertNotNull(property.getDefinition());
+
+ fileImport.checkin();
+ fileImport.checkout();
+ root.save();
+ }
}
13 years, 10 months
exo-jcr SVN: r2999 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-08-27 10:50:10 -0400 (Fri, 27 Aug 2010)
New Revision: 2999
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/DocumentViewImporter.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/SystemViewImporter.java
Log:
EXOJCR-880 : Determine if property is multi or single value from nodetype definition in import was implemented.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/DocumentViewImporter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/DocumentViewImporter.java 2010-08-27 14:15:21 UTC (rev 2998)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/DocumentViewImporter.java 2010-08-27 14:50:10 UTC (rev 2999)
@@ -348,30 +348,32 @@
{
PropertyDefinitionDatas vhdefs = null;
-
- if (nodeData.getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH))
+ if (defs.getAnyDefinition().isResidualSet())
{
- if (nodeData.getPrimaryTypeName().equals(Constants.NT_FROZENNODE))
+ if (nodeData.getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH))
{
- // get primaryType
- InternalQName fptName = locationFactory.parseJCRName(atts.get("jcr:frozenPrimaryType")).getInternalName();
-
- // get mixin types
- List<JCRName> mtNames = getJCRNames(atts.get("jcr:frozenMixinTypes"));
-
- InternalQName fmtName[] = new InternalQName[mtNames.size()];
-
- for (int i = 0; i < mtNames.size(); i++)
+ if (nodeData.getPrimaryTypeName().equals(Constants.NT_FROZENNODE))
{
- fmtName[i] = new InternalQName(mtNames.get(i).getNamespace(), mtNames.get(i).getName());
+ // get primaryType
+ InternalQName fptName = locationFactory.parseJCRName(atts.get("jcr:frozenPrimaryType")).getInternalName();
+
+ // get mixin types
+ List<JCRName> mtNames = getJCRNames(atts.get("jcr:frozenMixinTypes"));
+
+ InternalQName fmtName[] = new InternalQName[mtNames.size()];
+
+ for (int i = 0; i < mtNames.size(); i++)
+ {
+ fmtName[i] = new InternalQName(mtNames.get(i).getNamespace(), mtNames.get(i).getName());
+ }
+
+ vhdefs = nodeTypeDataManager.getPropertyDefinitions(propName, fptName, fmtName);
+
+ if (vhdefs != null)
+ {
+ isMultivalue = (vhdefs.getDefinition(true) != null ? true : false);
+ }
}
-
- vhdefs = nodeTypeDataManager.getPropertyDefinitions(propName, fptName, fmtName);
-
- if (vhdefs != null)
- {
- isMultivalue = (vhdefs.getDefinition(true) != null ? true : false);
- }
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/SystemViewImporter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/SystemViewImporter.java 2010-08-27 14:15:21 UTC (rev 2998)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/SystemViewImporter.java 2010-08-27 14:50:10 UTC (rev 2999)
@@ -339,16 +339,6 @@
*/
private void checkPropertis(NodePropertiesInfo currentNodePropertiesInfo) throws RepositoryException
{
- currentNodePropertiesInfo.getNode();
- currentNodePropertiesInfo.getNode().getQPath();
- currentNodePropertiesInfo.getNode().getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH);
-
- currentNodePropertiesInfo.getNode();
- currentNodePropertiesInfo.getNode().getPrimaryTypeName();
- currentNodePropertiesInfo.getNode().getPrimaryTypeName().equals(Constants.NT_FROZENNODE);
-
-
-
if (currentNodePropertiesInfo.getNode().getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH)
&& currentNodePropertiesInfo.getNode().getPrimaryTypeName().equals(Constants.NT_FROZENNODE))
{
@@ -391,17 +381,25 @@
{
throw new RepositoryException(e.getMessage(), e);
}
+
+ InternalQName nodePrimaryTypeName = currentNodePropertiesInfo.getNode().getPrimaryTypeName();
+ InternalQName[] nodeMixinTypeName = currentNodePropertiesInfo.getNode().getMixinTypeNames();
for (ImportPropertyData propertyData : currentNodePropertiesInfo.getProperties())
{
- PropertyDefinitionDatas vhdefs =
- nodeTypeDataManager.getPropertyDefinitions(propertyData.getQName(), fptName, fmtNames
- .toArray(new InternalQName[fmtNames.size()]));
-
- if (vhdefs != null)
+ PropertyDefinitionDatas defs = nodeTypeDataManager.getPropertyDefinitions(propertyData.getQName(), nodePrimaryTypeName, nodeMixinTypeName);
+
+ if (defs == null || (defs != null && defs.getAnyDefinition().isResidualSet()))
{
- boolean isMultivalue = (vhdefs.getDefinition(true) != null ? true : false);
- propertyData.setMultivalue(isMultivalue);
+ PropertyDefinitionDatas vhdefs =
+ nodeTypeDataManager.getPropertyDefinitions(propertyData.getQName(), fptName, fmtNames
+ .toArray(new InternalQName[fmtNames.size()]));
+
+ if (vhdefs != null)
+ {
+ boolean isMultivalue = (vhdefs.getDefinition(true) != null ? true : false);
+ propertyData.setMultivalue(isMultivalue);
+ }
}
}
}
13 years, 10 months
exo-jcr SVN: r2998 - core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-08-27 10:15:21 -0400 (Fri, 27 Aug 2010)
New Revision: 2998
Modified:
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSExcelDocumentReader.java
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java
Log:
EXOJCR-886: fixing test on Excel documents (fixed date asserting)
Modified: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSExcelDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSExcelDocumentReader.java 2010-08-27 08:46:34 UTC (rev 2997)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSExcelDocumentReader.java 2010-08-27 14:15:21 UTC (rev 2998)
@@ -21,6 +21,8 @@
import org.exoplatform.services.document.DocumentReaderService;
import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
/**
* Created by The eXo Platform SAS Author : Sergey Karpenko
@@ -31,8 +33,11 @@
public class TestMSExcelDocumentReader extends BaseStandaloneTest
{
+ private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
+
DocumentReaderService service;
-
+
+ @Override
public void setUp() throws Exception
{
super.setUp();
@@ -46,20 +51,56 @@
{
String text = service.getDocumentReader("application/excel").getContentAsText(is);
String expected =
- "Ronaldo Eric Cantona Kaka Ronaldonho "
- + "ID Group Functionality Executor Begin End Tested "
- + "XNNL XNNL Xay dung vung quan li nguyen lieu NamPH 2005-02-02 00:00:00.000+0200 2005-10-02 00:00:00.000+0300 Tested "
- + "XNNL XNNL XNNL_HAVEST NamPH 1223554.0 2005-10-01 00:00:00.000+0300 Tested "
- + "XNNL XNNL XNNL_PIECE_OF_GROUND NamPH 2005-10-12 00:00:00.000+0300 2005-10-02 00:00:00.000+0300 Tested "
- + "XNNL XNNL XNNL_76 NamPH TRUE() 1984-12-10 00:00:00.000+0200 No "
- + "XNNL XNNL XNNL_CREATE_REAP NamPH none 2005-10-03 00:00:00.000+0300 No "
- + "XNNL XNNL XNNL_SCALE NamPH 1984-12-10 00:00:00.000+0200 2005-10-05 00:00:00.000+0300 Tested "
- + "XNNL XNNL LASUCO_PROJECT NamPH 2005-10-05 00:00:00.000+0300 2005-10-06 00:00:00.000+0300 No "
+ "Ronaldo Eric Cantona Kaka Ronaldonho " + "ID Group Functionality Executor Begin End Tested "
+ + "XNNL XNNL Xay dung vung quan li nguyen lieu NamPH "
+ + getDate(2005, 2, 2)
+ + " "
+ + getDate(2005, 10, 2)
+ + " Tested "
+ + "XNNL XNNL XNNL_HAVEST NamPH 1223554.0 "
+ + getDate(2005, 10, 1)
+ + " Tested "
+ + "XNNL XNNL XNNL_PIECE_OF_GROUND NamPH "
+ + getDate(2005, 10, 12)
+ + " "
+ + getDate(2005, 10, 2)
+ + " Tested "
+ + "XNNL XNNL XNNL_76 NamPH TRUE() "
+ + getDate(1984, 12, 10)
+ + " No "
+ + "XNNL XNNL XNNL_CREATE_REAP NamPH none "
+ + getDate(2005, 10, 3)
+ + " No "
+ + "XNNL XNNL XNNL_SCALE NamPH "
+ + getDate(1984, 12, 10)
+ + " "
+ + getDate(2005, 10, 5)
+ + " Tested "
+ + "XNNL XNNL LASUCO_PROJECT NamPH "
+ + getDate(2005, 10, 5)
+ + " "
+ + getDate(2005, 10, 6)
+ + " No "
+ "XNNL XNNL LASUCO_PROJECT NamPH Tested "
- + "XNNL XNNL XNNL_BRANCH NamPH 2005-12-12 00:00:00.000+0200 2005-06-10 00:00:00.000+0300 Tested "
- + "XNNL XNNL XNNL_SUGAR_RACE NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No "
- + "XNNL XNNL F_XNNL_DISTRI NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 Tested "
- + "XNNL XNNL XNNL_LASUCO_USER NamPH 2005-09-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No";
+ + "XNNL XNNL XNNL_BRANCH NamPH "
+ + getDate(2005, 12, 12)
+ + " "
+ + getDate(2005, 6, 10)
+ + " Tested "
+ + "XNNL XNNL XNNL_SUGAR_RACE NamPH "
+ + getDate(2005, 5, 9)
+ + " "
+ + getDate(2005, 6, 10)
+ + " No "
+ + "XNNL XNNL F_XNNL_DISTRI NamPH "
+ + getDate(2005, 5, 9)
+ + " "
+ + getDate(2005, 6, 10)
+ + " Tested "
+ + "XNNL XNNL XNNL_LASUCO_USER NamPH "
+ + getDate(2005, 9, 9)
+ + " "
+ + getDate(2005, 6, 10) + " No";
assertEquals("Wrong string returned", normalizeWhitespaces(expected), normalizeWhitespaces(text));
}
@@ -69,4 +110,13 @@
}
}
+
+ public String getDate(int year, int month, int day)
+ {
+ Calendar date = Calendar.getInstance();
+ date.setTimeInMillis(0);
+ date.set(year, month - 1, day, 0, 0, 0);
+
+ return (DATE_FORMAT.format(date.getTime()));
+ }
}
Modified: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java 2010-08-27 08:46:34 UTC (rev 2997)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java 2010-08-27 14:15:21 UTC (rev 2998)
@@ -21,6 +21,8 @@
import org.exoplatform.services.document.DocumentReaderService;
import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
/**
* Created by The eXo Platform SAS Author : Sergey Karpenko
@@ -31,6 +33,9 @@
public class TestMSXExcelDocumentReader extends BaseStandaloneTest
{
+
+ private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
+
DocumentReaderService service;
@Override
@@ -48,21 +53,58 @@
String text =
service.getDocumentReader("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
.getContentAsText(is);
+
String expected =
- "Ronaldo Eric Cantona Kaka Ronaldonho "
- + "ID Group Functionality Executor Begin End Tested "
- + "XNNL XNNL Xay dung vung quan li nguyen lieu NamPH 2005-02-02 00:00:00.000+0200 2005-10-02 00:00:00.000+0300 Tested "
- + "XNNL XNNL XNNL_HAVEST NamPH 1223554.0 2005-10-01 00:00:00.000+0300 Tested "
- + "XNNL XNNL XNNL_PIECE_OF_GROUND NamPH 2005-10-12 00:00:00.000+0300 2005-10-02 00:00:00.000+0300 Tested "
- + "XNNL XNNL XNNL_76 NamPH TRUE() 1984-12-10 00:00:00.000+0200 No "
- + "XNNL XNNL XNNL_CREATE_REAP NamPH none 2005-10-03 00:00:00.000+0300 No "
- + "XNNL XNNL XNNL_SCALE NamPH 1984-12-10 00:00:00.000+0200 2005-10-05 00:00:00.000+0300 Tested "
- + "XNNL XNNL LASUCO_PROJECT NamPH 2005-10-05 00:00:00.000+0300 2005-10-06 00:00:00.000+0300 No "
+ "Ronaldo Eric Cantona Kaka Ronaldonho " + "ID Group Functionality Executor Begin End Tested "
+ + "XNNL XNNL Xay dung vung quan li nguyen lieu NamPH "
+ + getDate(2005, 2, 2)
+ + " "
+ + getDate(2005, 10, 2)
+ + " Tested "
+ + "XNNL XNNL XNNL_HAVEST NamPH 1223554.0 "
+ + getDate(2005, 10, 1)
+ + " Tested "
+ + "XNNL XNNL XNNL_PIECE_OF_GROUND NamPH "
+ + getDate(2005, 10, 12)
+ + " "
+ + getDate(2005, 10, 2)
+ + " Tested "
+ + "XNNL XNNL XNNL_76 NamPH TRUE() "
+ + getDate(1984, 12, 10)
+ + " No "
+ + "XNNL XNNL XNNL_CREATE_REAP NamPH none "
+ + getDate(2005, 10, 3)
+ + " No "
+ + "XNNL XNNL XNNL_SCALE NamPH "
+ + getDate(1984, 12, 10)
+ + " "
+ + getDate(2005, 10, 5)
+ + " Tested "
+ + "XNNL XNNL LASUCO_PROJECT NamPH "
+ + getDate(2005, 10, 5)
+ + " "
+ + getDate(2005, 10, 6)
+ + " No "
+ "XNNL XNNL LASUCO_PROJECT NamPH Tested "
- + "XNNL XNNL XNNL_BRANCH NamPH 2005-12-12 00:00:00.000+0200 2005-06-10 00:00:00.000+0300 Tested "
- + "XNNL XNNL XNNL_SUGAR_RACE NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No "
- + "XNNL XNNL F_XNNL_DISTRI NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 Tested "
- + "XNNL XNNL XNNL_LASUCO_USER NamPH 2005-09-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No";
+ + "XNNL XNNL XNNL_BRANCH NamPH "
+ + getDate(2005, 12, 12)
+ + " "
+ + getDate(2005, 6, 10)
+ + " Tested "
+ + "XNNL XNNL XNNL_SUGAR_RACE NamPH "
+ + getDate(2005, 5, 9)
+ + " "
+ + getDate(2005, 6, 10)
+ + " No "
+ + "XNNL XNNL F_XNNL_DISTRI NamPH "
+ + getDate(2005, 5, 9)
+ + " "
+ + getDate(2005, 6, 10)
+ + " Tested "
+ + "XNNL XNNL XNNL_LASUCO_USER NamPH "
+ + getDate(2005, 9, 9)
+ + " "
+ + getDate(2005, 6, 10) + " No";
assertEquals("Wrong string returned", normalizeWhitespaces(expected), normalizeWhitespaces(text));
}
@@ -71,4 +113,14 @@
is.close();
}
}
+
+ public String getDate(int year, int month, int day)
+ {
+ Calendar date = Calendar.getInstance();
+ date.setTimeInMillis(0);
+ date.set(year, month - 1, day, 0, 0, 0);
+
+ return (DATE_FORMAT.format(date.getTime()));
+ }
+
}
13 years, 10 months
exo-jcr SVN: r2997 - core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-08-27 04:46:34 -0400 (Fri, 27 Aug 2010)
New Revision: 2997
Modified:
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/BaseStandaloneTest.java
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestHtmlDocumentReader.java
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSExcelDocumentReader.java
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSOutlookDocumentReader.java
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSWordDocumentReader.java
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXPPTDocumentReader.java
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXWordDocumentReader.java
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestOpenOfficeDocumentReader.java
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPDFDocumentReader.java
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPPTDocumentReader.java
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPropertiesExtracting.java
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestTextPlainDocumentReader.java
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestXMLDocumentReader.java
Log:
EXOJCR-886: tests updated
Modified: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/BaseStandaloneTest.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/BaseStandaloneTest.java 2010-08-27 07:03:02 UTC (rev 2996)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/BaseStandaloneTest.java 2010-08-27 08:46:34 UTC (rev 2997)
@@ -83,4 +83,11 @@
return f.delete();
}
+ public String normalizeWhitespaces(String str)
+ {
+ str = str.trim();
+ str = str.replaceAll("\\s+", " ");
+ return str;
+ }
+
}
Modified: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestHtmlDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestHtmlDocumentReader.java 2010-08-27 07:03:02 UTC (rev 2996)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestHtmlDocumentReader.java 2010-08-27 08:46:34 UTC (rev 2997)
@@ -32,21 +32,28 @@
public class TestHtmlDocumentReader extends BaseStandaloneTest
{
- DocumentReaderService service_;
+ DocumentReaderService service;
public void setUp() throws Exception
{
super.setUp();
- service_ = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
+ service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
}
public void testGetContentAsString() throws Exception
{
InputStream is = TestHtmlDocumentReader.class.getResourceAsStream("/test.html");
- String mimeType = mimetypeResolver.getMimeType("test.html");
+ try
+ {
+ String mimeType = mimetypeResolver.getMimeType("test.html");
- DocumentReader dr = service_.getDocumentReader(mimeType);
- String text = dr.getContentAsText(is);
- // TODO text is too huge, need small test file
+ DocumentReader dr = service.getDocumentReader(mimeType);
+ String text = dr.getContentAsText(is);
+ assertTrue(text.contains("This is the third maintenance release of the redesigned 2.0"));
+ }
+ finally
+ {
+ is.close();
+ }
}
}
Modified: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSExcelDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSExcelDocumentReader.java 2010-08-27 07:03:02 UTC (rev 2996)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSExcelDocumentReader.java 2010-08-27 08:46:34 UTC (rev 2997)
@@ -31,46 +31,42 @@
public class TestMSExcelDocumentReader extends BaseStandaloneTest
{
- DocumentReaderService service_;
+ DocumentReaderService service;
public void setUp() throws Exception
{
super.setUp();
- service_ = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
+ service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
}
public void testGetContentAsString() throws Exception
{
InputStream is = TestMSExcelDocumentReader.class.getResourceAsStream("/test.xls");
- String text = service_.getDocumentReader("application/excel").getContentAsText(is);
- System.out.println(" text [" + text + "]");
- /*
- * String etalon =
- * "Ronaldo Eric Cantona Kaka Ronaldonho ID Group Functionality Executor Begin End Tested "
- * +
- * "XNNL XNNL Xay dung vung quan li nguyen lieu NamPH 2005-02-02 00:00:00.000+0200 2005-10-02 00:00:00.000+0300 Tested "
- * +
- * "XNNL XNNL XNNL_HAVEST NamPH 1223554.0 2005-10-01 00:00:00.000+0300 Tested "
- * +
- * "XNNL XNNL XNNL_PIECE_OF_GROUND NamPH 2005-10-12 00:00:00.000+0300 2005-10-02 00:00:00.000+0300 Tested "
- * +"XNNL XNNL XNNL_76 NamPH TRUE 1984-12-10 00:00:00.000+0200 No "
- * +"XNNL XNNL XNNL_CREATE_REAP NamPH none 2005-10-03 00:00:00.000+0300 No "
- * +
- * "XNNL XNNL XNNL_SCALE NamPH 1984-12-10 00:00:00.000+0200 2005-10-05 00:00:00.000+0300 Tested "
- * +
- * "XNNL XNNL LASUCO_PROJECT NamPH 2005-10-05 00:00:00.000+0300 2005-10-06 00:00:00.000+0300 No "
- * +"XNNL XNNL LASUCO_PROJECT NamPH Tested "+
- * "XNNL XNNL XNNL_BRANCH NamPH 2005-12-12 00:00:00.000+0200 2005-06-10 00:00:00.000+0300 Tested "
- * +
- * "XNNL XNNL XNNL_SUGAR_RACE NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No "
- * +
- * "XNNL XNNL F_XNNL_DISTRI NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 Tested "
- * +
- * "XNNL XNNL XNNL_LASUCO_USER NamPH 2005-09-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No "
- * ; System.out.println(" etalon ["+etalon+"]");
- * assertEquals("String length is incorect",etalon.length(),text.length());
- * assertEquals("Wrong string returned",etalon ,text );
- */
+ try
+ {
+ String text = service.getDocumentReader("application/excel").getContentAsText(is);
+ String expected =
+ "Ronaldo Eric Cantona Kaka Ronaldonho "
+ + "ID Group Functionality Executor Begin End Tested "
+ + "XNNL XNNL Xay dung vung quan li nguyen lieu NamPH 2005-02-02 00:00:00.000+0200 2005-10-02 00:00:00.000+0300 Tested "
+ + "XNNL XNNL XNNL_HAVEST NamPH 1223554.0 2005-10-01 00:00:00.000+0300 Tested "
+ + "XNNL XNNL XNNL_PIECE_OF_GROUND NamPH 2005-10-12 00:00:00.000+0300 2005-10-02 00:00:00.000+0300 Tested "
+ + "XNNL XNNL XNNL_76 NamPH TRUE() 1984-12-10 00:00:00.000+0200 No "
+ + "XNNL XNNL XNNL_CREATE_REAP NamPH none 2005-10-03 00:00:00.000+0300 No "
+ + "XNNL XNNL XNNL_SCALE NamPH 1984-12-10 00:00:00.000+0200 2005-10-05 00:00:00.000+0300 Tested "
+ + "XNNL XNNL LASUCO_PROJECT NamPH 2005-10-05 00:00:00.000+0300 2005-10-06 00:00:00.000+0300 No "
+ + "XNNL XNNL LASUCO_PROJECT NamPH Tested "
+ + "XNNL XNNL XNNL_BRANCH NamPH 2005-12-12 00:00:00.000+0200 2005-06-10 00:00:00.000+0300 Tested "
+ + "XNNL XNNL XNNL_SUGAR_RACE NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No "
+ + "XNNL XNNL F_XNNL_DISTRI NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 Tested "
+ + "XNNL XNNL XNNL_LASUCO_USER NamPH 2005-09-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No";
+ assertEquals("Wrong string returned", normalizeWhitespaces(expected), normalizeWhitespaces(text));
+ }
+ finally
+ {
+ is.close();
+ }
+
}
}
Modified: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSOutlookDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSOutlookDocumentReader.java 2010-08-27 07:03:02 UTC (rev 2996)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSOutlookDocumentReader.java 2010-08-27 08:46:34 UTC (rev 2997)
@@ -32,12 +32,12 @@
public class TestMSOutlookDocumentReader extends BaseStandaloneTest
{
- DocumentReaderService service_;
+ DocumentReaderService service;
public void setUp() throws Exception
{
super.setUp();
- service_ = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
+ service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
}
public void testGetContentAsString() throws Exception
@@ -45,9 +45,15 @@
String name = "/test.msg";
InputStream is = BasicTestCase.class.getResourceAsStream(name);
assertNotNull(is);
-
- String text = service_.getDocumentReader("application/vnd.ms-outlook").getContentAsText(is);
- String etalon = "Goooogle\n" + "theme\n" + "Hello, this is the test outlook message.\r\n";
- assertEquals("Wrong string returned", etalon, text);
+ try
+ {
+ String text = service.getDocumentReader("application/vnd.ms-outlook").getContentAsText(is);
+ String etalon = "Goooogle\n" + "theme\n" + "Hello, this is the test outlook message.\r\n";
+ assertEquals("Wrong string returned", etalon, text);
+ }
+ finally
+ {
+ is.close();
+ }
}
}
Modified: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSWordDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSWordDocumentReader.java 2010-08-27 07:03:02 UTC (rev 2996)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSWordDocumentReader.java 2010-08-27 08:46:34 UTC (rev 2997)
@@ -31,38 +31,42 @@
public class TestMSWordDocumentReader extends BaseStandaloneTest
{
- DocumentReaderService service_;
+ DocumentReaderService service;
public void setUp() throws Exception
{
super.setUp();
- service_ = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
+ service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
}
public void testGetContentAsStringTemplate() throws Exception
{
InputStream is = TestMSWordDocumentReader.class.getResourceAsStream("/test.dot");
- String text = service_.getDocumentReader("application/msworddot").getContentAsText(is);
- System.out.println("text [" + text + "]");
- String etalon = "exotest";
- System.out.println("etalon [" + etalon + "]");
-
- System.out.println("[" + text.length() + "] [" + etalon.length() + "]");
- assertEquals("Wrong string returned", etalon, text);
+ try
+ {
+ String text = service.getDocumentReader("application/msworddot").getContentAsText(is);
+ String etalon = "exotest";
+ assertEquals("Wrong string returned", etalon, text);
+ }
+ finally
+ {
+ is.close();
+ }
}
public void testGetContentAsStringDoc() throws Exception
{
InputStream is = TestMSWordDocumentReader.class.getResourceAsStream("/test.doc");
- String text = service_.getDocumentReader("application/msword").getContentAsText(is);
- System.out.println("text [" + text + "]");
+ try
+ {
+ String text = service.getDocumentReader("application/msword").getContentAsText(is);
+ assertTrue(text
+ .contains("Before the test starts there is a directions section, which takes a few minutes to read"));
- /*
- * String etalon = "Hello.\n" +"This is the test document 12345\n"
- * +"Table\n" +"Title One Two\n" +"Hello_Title Hello_One Hello_Two\n";
- * System.out.println("etalon ["+etalon+"]");
- * System.out.println("["+text.length()+"] ["+etalon.length()+"]");
- * assertEquals("Wrong string returned",etalon ,text );
- */
+ }
+ finally
+ {
+ is.close();
+ }
}
}
Modified: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java 2010-08-27 07:03:02 UTC (rev 2996)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java 2010-08-27 08:46:34 UTC (rev 2997)
@@ -31,47 +31,44 @@
public class TestMSXExcelDocumentReader extends BaseStandaloneTest
{
- DocumentReaderService service_;
+ DocumentReaderService service;
@Override
public void setUp() throws Exception
{
super.setUp();
- service_ = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
+ service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
}
public void testGetContentAsString() throws Exception
{
InputStream is = TestMSXExcelDocumentReader.class.getResourceAsStream("/test.xlsx");
- String text = service_.getDocumentReader("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet").getContentAsText(is);
- System.out.println(" text [" + text + "]");
- /*
- * String etalon =
- * "Ronaldo Eric Cantona Kaka Ronaldonho ID Group Functionality Executor Begin End Tested "
- * +
- * "XNNL XNNL Xay dung vung quan li nguyen lieu NamPH 2005-02-02 00:00:00.000+0200 2005-10-02 00:00:00.000+0300 Tested "
- * +
- * "XNNL XNNL XNNL_HAVEST NamPH 1223554.0 2005-10-01 00:00:00.000+0300 Tested "
- * +
- * "XNNL XNNL XNNL_PIECE_OF_GROUND NamPH 2005-10-12 00:00:00.000+0300 2005-10-02 00:00:00.000+0300 Tested "
- * +"XNNL XNNL XNNL_76 NamPH TRUE 1984-12-10 00:00:00.000+0200 No "
- * +"XNNL XNNL XNNL_CREATE_REAP NamPH none 2005-10-03 00:00:00.000+0300 No "
- * +
- * "XNNL XNNL XNNL_SCALE NamPH 1984-12-10 00:00:00.000+0200 2005-10-05 00:00:00.000+0300 Tested "
- * +
- * "XNNL XNNL LASUCO_PROJECT NamPH 2005-10-05 00:00:00.000+0300 2005-10-06 00:00:00.000+0300 No "
- * +"XNNL XNNL LASUCO_PROJECT NamPH Tested "+
- * "XNNL XNNL XNNL_BRANCH NamPH 2005-12-12 00:00:00.000+0200 2005-06-10 00:00:00.000+0300 Tested "
- * +
- * "XNNL XNNL XNNL_SUGAR_RACE NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No "
- * +
- * "XNNL XNNL F_XNNL_DISTRI NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 Tested "
- * +
- * "XNNL XNNL XNNL_LASUCO_USER NamPH 2005-09-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No "
- * ; System.out.println(" etalon ["+etalon+"]");
- * assertEquals("String length is incorect",etalon.length(),text.length());
- * assertEquals("Wrong string returned",etalon ,text );
- */
+ try
+ {
+ String text =
+ service.getDocumentReader("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
+ .getContentAsText(is);
+ String expected =
+ "Ronaldo Eric Cantona Kaka Ronaldonho "
+ + "ID Group Functionality Executor Begin End Tested "
+ + "XNNL XNNL Xay dung vung quan li nguyen lieu NamPH 2005-02-02 00:00:00.000+0200 2005-10-02 00:00:00.000+0300 Tested "
+ + "XNNL XNNL XNNL_HAVEST NamPH 1223554.0 2005-10-01 00:00:00.000+0300 Tested "
+ + "XNNL XNNL XNNL_PIECE_OF_GROUND NamPH 2005-10-12 00:00:00.000+0300 2005-10-02 00:00:00.000+0300 Tested "
+ + "XNNL XNNL XNNL_76 NamPH TRUE() 1984-12-10 00:00:00.000+0200 No "
+ + "XNNL XNNL XNNL_CREATE_REAP NamPH none 2005-10-03 00:00:00.000+0300 No "
+ + "XNNL XNNL XNNL_SCALE NamPH 1984-12-10 00:00:00.000+0200 2005-10-05 00:00:00.000+0300 Tested "
+ + "XNNL XNNL LASUCO_PROJECT NamPH 2005-10-05 00:00:00.000+0300 2005-10-06 00:00:00.000+0300 No "
+ + "XNNL XNNL LASUCO_PROJECT NamPH Tested "
+ + "XNNL XNNL XNNL_BRANCH NamPH 2005-12-12 00:00:00.000+0200 2005-06-10 00:00:00.000+0300 Tested "
+ + "XNNL XNNL XNNL_SUGAR_RACE NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No "
+ + "XNNL XNNL F_XNNL_DISTRI NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 Tested "
+ + "XNNL XNNL XNNL_LASUCO_USER NamPH 2005-09-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No";
+ assertEquals("Wrong string returned", normalizeWhitespaces(expected), normalizeWhitespaces(text));
+ }
+ finally
+ {
+ is.close();
+ }
}
}
Modified: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXPPTDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXPPTDocumentReader.java 2010-08-27 07:03:02 UTC (rev 2996)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXPPTDocumentReader.java 2010-08-27 08:46:34 UTC (rev 2997)
@@ -31,25 +31,32 @@
public class TestMSXPPTDocumentReader extends BaseStandaloneTest
{
- DocumentReaderService service_;
+ DocumentReaderService service;
@Override
public void setUp() throws Exception
{
super.setUp();
- service_ = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
+ service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
}
public void testGetContentAsString() throws Exception
{
InputStream is = TestMSXPPTDocumentReader.class.getResourceAsStream("/test.pptx");
- String text =
- service_.getDocumentReader("application/vnd.openxmlformats-officedocument.presentationml.presentation")
- .getContentAsText(is);
- String etalon =
- "TEST POWERPOINT\n" + "Manchester United \n" + "AC Milan\n" + "SLIDE 2 \n" + "Eric Cantona\n" + "Kaka\n"
- + "Ronaldo\n" + "The natural scients universitys\n";
+ try
+ {
+ String text =
+ service.getDocumentReader("application/vnd.openxmlformats-officedocument.presentationml.presentation")
+ .getContentAsText(is);
+ String etalon =
+ "TEST POWERPOINT\n" + "Manchester United \n" + "AC Milan\n" + "SLIDE 2 \n" + "Eric Cantona\n" + "Kaka\n"
+ + "Ronaldo\n" + "The natural scients universitys\n";
- assertEquals("Wrong string returned", etalon, text);
+ assertEquals("Wrong string returned", etalon, text);
+ }
+ finally
+ {
+ is.close();
+ }
}
}
Modified: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXWordDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXWordDocumentReader.java 2010-08-27 07:03:02 UTC (rev 2996)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXWordDocumentReader.java 2010-08-27 08:46:34 UTC (rev 2997)
@@ -29,27 +29,36 @@
*/
public class TestMSXWordDocumentReader extends BaseStandaloneTest
{
- DocumentReaderService service_;
+ DocumentReaderService service;
@Override
public void setUp() throws Exception
{
super.setUp();
- service_ = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
+ service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
}
public void testGetContentAsStringDoc() throws Exception
{
InputStream is = TestMSXWordDocumentReader.class.getResourceAsStream("/test.docx");
- String text = service_.getDocumentReader("application/vnd.openxmlformats-officedocument.wordprocessingml.document").getContentAsText(is);
- System.out.println("text [" + text + "]");
+ try
+ {
+ String text =
+ service.getDocumentReader("application/vnd.openxmlformats-officedocument.wordprocessingml.document")
+ .getContentAsText(is);
+ System.out.println("text [" + text + "]");
- /*
- * String etalon = "Hello.\n" +"This is the test document 12345\n"
- * +"Table\n" +"Title One Two\n" +"Hello_Title Hello_One Hello_Two\n";
- * System.out.println("etalon ["+etalon+"]");
- * System.out.println("["+text.length()+"] ["+etalon.length()+"]");
- * assertEquals("Wrong string returned",etalon ,text );
- */
+ /*
+ * String etalon = "Hello.\n" +"This is the test document 12345\n"
+ * +"Table\n" +"Title One Two\n" +"Hello_Title Hello_One Hello_Two\n";
+ * System.out.println("etalon ["+etalon+"]");
+ * System.out.println("["+text.length()+"] ["+etalon.length()+"]");
+ * assertEquals("Wrong string returned",etalon ,text );
+ */
+ }
+ finally
+ {
+ is.close();
+ }
}
}
Modified: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestOpenOfficeDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestOpenOfficeDocumentReader.java 2010-08-27 07:03:02 UTC (rev 2996)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestOpenOfficeDocumentReader.java 2010-08-27 08:46:34 UTC (rev 2997)
@@ -31,52 +31,59 @@
public class TestOpenOfficeDocumentReader extends BaseStandaloneTest
{
- DocumentReaderService service_;
+ DocumentReaderService service;
public void setUp() throws Exception
{
super.setUp();
- service_ = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
+ service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
}
public void testGetContentAsString() throws Exception
{
InputStream is = TestOpenOfficeDocumentReader.class.getResourceAsStream("/test.odt");
- String text = service_.getDocumentReader("application/vnd.oasis.opendocument.text").getContentAsText(is);
- System.out.println("[" + text + "]");
- /*
- * String etalon = "Subscription:" +
- * "\tEULA with add on warranties and non GPL viral effect (all Customer's development free of GPL license limitations). This agreement continues to be valid even if customers do not renew their subscription.\n"
- * +
- * "\tProduct documentation including user and admin guides to eXo platform portal, ECM, JCR, and Portlet Container. (currently we have all the docs accessible for free but it will not)\n"
- * +
- * "\tAccess to all Flash tutorial gives a visual guide to eXo platform and demonstrates a comprehensive tutorial that enhance the understanding of eXo products. (only part of Flash tutorials are accessible for free)\n"
- * +
- * "\tAdvanced Installer is an application that makes it quick and easy to install eXo platform products with simple clicks and allows better configuration to integrate existing database and directories (LDAP) in a multi platform environment.\n"
- * +
- * "\tUnlimited access to online premium forum (customer request tracking?) support, you will get answer from eXo platform company technical specialist employees. (TODO) \n"
- * +
- * "\tUnlimited email support within 48 hours response time for limited contact names per CPU.(i think we may join it with prev item using term customer request tracking with email notification)\n"
- * +
- * "\tUpdate alert will send out email periodically to subscribers all the latest change in eXo documentations, flash tutorials, and product services. (TODO)\n"
- * +
- * "\tTechnical code improvement alert will send out email periodically to subscribers to inform of all the latest code patches, latest version, latest code improvement download. (TODO)\n"
- * +
- * "\tKnowledge Base subscribers can access to all of eXo platform wiki knowledge bases. (TODO, i do not think we may put it into agreement yet)\n"
- * +
- * "\tFeature Request Priority As customers you have priorities to request the latest features improvement for any of eXo products next version. (what does it mean?)\n"
- * + "\n" +
- * "Subscription is annual and per CPU because it is the unit of load increase and so more support demand. Subscription advantages are:\n"
- * + "\tEULA � it is obligatory to be Subscriber to get EULA\n" +
- * "\tAdditional documentations (Guides, Flash tutorials)\n" +
- * "\tAdditional software (Installer)\n" +
- * "\tAdditional product/documentation changes notifications\n" +
- * "\tProfessional support: limited contact name (3 customer contact with 1 eXo contact per CPU), 48 hours to answer via email\n"
- * + "\tFeature request priority (also depending on CPU number)\n" + "\n";
- * System.out.println("["+etalon+"]");
- * System.out.println("TEXT size ["+text.
- * length()+"] ETALON LEN ["+etalon.length()+"]");
- * assertEquals("Wrong string returned", etalon, text);
- */
+ try
+ {
+ String text = service.getDocumentReader("application/vnd.oasis.opendocument.text").getContentAsText(is);
+ System.out.println("[" + text + "]");
+ /*
+ * String etalon = "Subscription:" +
+ * "\tEULA with add on warranties and non GPL viral effect (all Customer's development free of GPL license limitations). This agreement continues to be valid even if customers do not renew their subscription.\n"
+ * +
+ * "\tProduct documentation including user and admin guides to eXo platform portal, ECM, JCR, and Portlet Container. (currently we have all the docs accessible for free but it will not)\n"
+ * +
+ * "\tAccess to all Flash tutorial gives a visual guide to eXo platform and demonstrates a comprehensive tutorial that enhance the understanding of eXo products. (only part of Flash tutorials are accessible for free)\n"
+ * +
+ * "\tAdvanced Installer is an application that makes it quick and easy to install eXo platform products with simple clicks and allows better configuration to integrate existing database and directories (LDAP) in a multi platform environment.\n"
+ * +
+ * "\tUnlimited access to online premium forum (customer request tracking?) support, you will get answer from eXo platform company technical specialist employees. (TODO) \n"
+ * +
+ * "\tUnlimited email support within 48 hours response time for limited contact names per CPU.(i think we may join it with prev item using term customer request tracking with email notification)\n"
+ * +
+ * "\tUpdate alert will send out email periodically to subscribers all the latest change in eXo documentations, flash tutorials, and product services. (TODO)\n"
+ * +
+ * "\tTechnical code improvement alert will send out email periodically to subscribers to inform of all the latest code patches, latest version, latest code improvement download. (TODO)\n"
+ * +
+ * "\tKnowledge Base subscribers can access to all of eXo platform wiki knowledge bases. (TODO, i do not think we may put it into agreement yet)\n"
+ * +
+ * "\tFeature Request Priority As customers you have priorities to request the latest features improvement for any of eXo products next version. (what does it mean?)\n"
+ * + "\n" +
+ * "Subscription is annual and per CPU because it is the unit of load increase and so more support demand. Subscription advantages are:\n"
+ * + "\tEULA � it is obligatory to be Subscriber to get EULA\n" +
+ * "\tAdditional documentations (Guides, Flash tutorials)\n" +
+ * "\tAdditional software (Installer)\n" +
+ * "\tAdditional product/documentation changes notifications\n" +
+ * "\tProfessional support: limited contact name (3 customer contact with 1 eXo contact per CPU), 48 hours to answer via email\n"
+ * + "\tFeature request priority (also depending on CPU number)\n" + "\n";
+ * System.out.println("["+etalon+"]");
+ * System.out.println("TEXT size ["+text.
+ * length()+"] ETALON LEN ["+etalon.length()+"]");
+ * assertEquals("Wrong string returned", etalon, text);
+ */
+ }
+ finally
+ {
+ is.close();
+ }
}
}
Modified: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPDFDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPDFDocumentReader.java 2010-08-27 07:03:02 UTC (rev 2996)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPDFDocumentReader.java 2010-08-27 08:46:34 UTC (rev 2997)
@@ -31,21 +31,27 @@
public class TestPDFDocumentReader extends BaseStandaloneTest
{
- DocumentReaderService service_;
+ DocumentReaderService service;
public void setUp() throws Exception
{
super.setUp();
- service_ = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
+ service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
}
public void testGetContentAsString() throws Exception
{
InputStream is = TestPDFDocumentReader.class.getResourceAsStream("/test.pdf");
- String text = service_.getDocumentReader("application/pdf").getContentAsText(is);
- String etalon = "Hello\nThis is my first Cocoon page!\npage 1 \n";
+ try
+ {
+ String text = service.getDocumentReader("application/pdf").getContentAsText(is);
+ String expected = "Hello This is my first Cocoon page! page 1";
- System.out.println("[" + text + "]");
- // assertEquals("Wrong string returned",etalon ,text );
+ assertEquals("Wrong string returned", normalizeWhitespaces(expected), normalizeWhitespaces(text));
+ }
+ finally
+ {
+ is.close();
+ }
}
}
Modified: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPPTDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPPTDocumentReader.java 2010-08-27 07:03:02 UTC (rev 2996)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPPTDocumentReader.java 2010-08-27 08:46:34 UTC (rev 2997)
@@ -31,21 +31,28 @@
public class TestPPTDocumentReader extends BaseStandaloneTest
{
- DocumentReaderService service_;
+ DocumentReaderService service;
public void setUp() throws Exception
{
super.setUp();
- service_ = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
+ service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
}
public void testGetContentAsString() throws Exception
{
InputStream is = TestPPTDocumentReader.class.getResourceAsStream("/test.ppt");
- String text = service_.getDocumentReader("application/powerpoint").getContentAsText(is);
- String etalon =
- "TEST POWERPOINT\n" + "Manchester United \n" + "AC Milan\n" + "SLIDE 2 \n" + "Eric Cantona\n" + "Kaka\n"
- + "Ronaldo\n" + "The natural scients universitys\n\n";
- assertEquals("Wrong string returned", etalon, text);
+ try
+ {
+ String text = service.getDocumentReader("application/powerpoint").getContentAsText(is);
+ String etalon =
+ "TEST POWERPOINT\n" + "Manchester United \n" + "AC Milan\n" + "SLIDE 2 \n" + "Eric Cantona\n" + "Kaka\n"
+ + "Ronaldo\n" + "The natural scients universitys\n\n";
+ assertEquals("Wrong string returned", etalon, text);
+ }
+ finally
+ {
+ is.close();
+ }
}
}
Modified: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPropertiesExtracting.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPropertiesExtracting.java 2010-08-27 07:03:02 UTC (rev 2996)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPropertiesExtracting.java 2010-08-27 08:46:34 UTC (rev 2997)
@@ -31,66 +31,122 @@
public class TestPropertiesExtracting extends BaseStandaloneTest
{
- DocumentReaderService service_;
+ DocumentReaderService service;
public void setUp() throws Exception
{
super.setUp();
- service_ = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
+ service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
+ // service = new DocumentReaderServiceImpl(null);
+ // InitParams params = new InitParams();
+ // service.addDocumentReader(new TextPlainDocumentReader(params));
+ // service.addDocumentReader(new XMLDocumentReader());
+ // service.addDocumentReader(new HTMLDocumentReader(null));
+ // service.addDocumentReader(new MSExcelDocumentReader());
+ // service.addDocumentReader(new MSOutlookDocumentReader());
+ // service.addDocumentReader(new MSWordDocumentReader());
+ // service.addDocumentReader(new MSXExcelDocumentReader());
+ // service.addDocumentReader(new MSXPPTDocumentReader());
+ // service.addDocumentReader(new MSXWordDocumentReader());
+ // service.addDocumentReader(new OpenOfficeDocumentReader());
+ // service.addDocumentReader(new PDFDocumentReader());
+ // service.addDocumentReader(new PPTDocumentReader());
}
public void testPDFDocumentReaderService() throws Exception
{
InputStream is = TestPropertiesExtracting.class.getResourceAsStream("/test.pdf");
- DocumentReader rdr = service_.getDocumentReader("application/pdf");
- Properties props = rdr.getProperties(is);
- printProps(props);
+ try
+ {
+ DocumentReader rdr = service.getDocumentReader("application/pdf");
+ Properties props = rdr.getProperties(is);
+ printProps(props);
+ }
+ finally
+ {
+ is.close();
+ }
}
public void testPDFDocumentReaderServiceXMPMetadata() throws Exception
{
InputStream is = TestPropertiesExtracting.class.getResourceAsStream("/MyTest.pdf");
- DocumentReader rdr = service_.getDocumentReader("application/pdf");
+ try
+ {
+ DocumentReader rdr = service.getDocumentReader("application/pdf");
- Properties testprops = rdr.getProperties(is);
- printProps(testprops);
+ Properties testprops = rdr.getProperties(is);
+ printProps(testprops);
- Properties etalon = new Properties();
- etalon.put(DCMetaData.TITLE, "Test de convertion de fichier tif");
- etalon.put(DCMetaData.CREATOR, "Christian Klaus");
- etalon.put(DCMetaData.SUBJECT, "20080901 TEST Christian Etat OK");
- Calendar c = ISO8601.parseEx("2008-09-01T08:01:10+00:00");;
- etalon.put(DCMetaData.DATE, c);
+ Properties etalon = new Properties();
+ etalon.put(DCMetaData.TITLE, "Test de convertion de fichier tif");
+ etalon.put(DCMetaData.CREATOR, "Christian Klaus");
+ etalon.put(DCMetaData.SUBJECT, "20080901 TEST Christian Etat OK");
+ Calendar c = ISO8601.parseEx("2008-09-01T08:01:10+00:00");;
+ etalon.put(DCMetaData.DATE, c);
- evalProps(etalon, testprops);
+ evalProps(etalon, testprops);
+ }
+ finally
+ {
+ is.close();
+ }
}
public void testWordDocumentReaderService() throws Exception
{
InputStream is = TestPropertiesExtracting.class.getResourceAsStream("/test.doc");
- Properties props = service_.getDocumentReader("application/msword").getProperties(is);
- printProps(props);
+ try
+ {
+ Properties props = service.getDocumentReader("application/msword").getProperties(is);
+ printProps(props);
+ }
+ finally
+ {
+ is.close();
+ }
}
public void testPPTDocumentReaderService() throws Exception
{
InputStream is = TestPropertiesExtracting.class.getResourceAsStream("/test.ppt");
- Properties props = service_.getDocumentReader("application/powerpoint").getProperties(is);
- printProps(props);
+ try
+ {
+ Properties props = service.getDocumentReader("application/powerpoint").getProperties(is);
+ printProps(props);
+ }
+ finally
+ {
+ is.close();
+ }
}
public void testExcelDocumentReaderService() throws Exception
{
InputStream is = TestPropertiesExtracting.class.getResourceAsStream("/test.xls");
- Properties props = service_.getDocumentReader("application/excel").getProperties(is);
- printProps(props);
+ try
+ {
+ Properties props = service.getDocumentReader("application/excel").getProperties(is);
+ printProps(props);
+ }
+ finally
+ {
+ is.close();
+ }
}
public void testOODocumentReaderService() throws Exception
{
InputStream is = TestPropertiesExtracting.class.getResourceAsStream("/test.odt");
- Properties props = service_.getDocumentReader("application/vnd.oasis.opendocument.text").getProperties(is);
- printProps(props);
+ try
+ {
+ Properties props = service.getDocumentReader("application/vnd.oasis.opendocument.text").getProperties(is);
+ printProps(props);
+ }
+ finally
+ {
+ is.close();
+ }
}
private void printProps(Properties props)
Modified: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestTextPlainDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestTextPlainDocumentReader.java 2010-08-27 07:03:02 UTC (rev 2996)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestTextPlainDocumentReader.java 2010-08-27 08:46:34 UTC (rev 2997)
@@ -31,28 +31,42 @@
public class TestTextPlainDocumentReader extends BaseStandaloneTest
{
- DocumentReaderService service_;
+ DocumentReaderService service;
public void setUp() throws Exception
{
super.setUp();
- service_ = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
+ service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
}
public void testGetContentAsString() throws Exception
{
InputStream is = TestTextPlainDocumentReader.class.getResourceAsStream("/test.txt");
- String text = service_.getDocumentReader("text/plain").getContentAsText(is);
- assertEquals("Wrong string returned", "This is a test text\n", text);
+ try
+ {
+ String text = service.getDocumentReader("text/plain").getContentAsText(is);
+ assertEquals("Wrong string returned", "This is a test text\n", text);
+ }
+ finally
+ {
+ is.close();
+ }
}
public void testGetContentAsStringWithEncoding() throws Exception
{
InputStream is = TestTextPlainDocumentReader.class.getResourceAsStream("/testUTF8.txt");
- String text = service_.getDocumentReader("text/plain").getContentAsText(is, "UTF-8");
- String etalon =
- "\ufeff\u0426\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u0438\u0439 \u0442\u0435\u043a\u0441\u0442. \u042d\u0442\u043e \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0442\u0435\u043a\u0441\u0442.";
- assertEquals("Wrong string returned", etalon, text);
+ try
+ {
+ String text = service.getDocumentReader("text/plain").getContentAsText(is, "UTF-8");
+ String expected =
+ "\ufeff\u0426\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u0438\u0439 \u0442\u0435\u043a\u0441\u0442. \u042d\u0442\u043e \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0442\u0435\u043a\u0441\u0442.";
+ assertEquals("Wrong string returned", expected, text);
+ }
+ finally
+ {
+ is.close();
+ }
}
}
Modified: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestXMLDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestXMLDocumentReader.java 2010-08-27 07:03:02 UTC (rev 2996)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestXMLDocumentReader.java 2010-08-27 08:46:34 UTC (rev 2997)
@@ -31,38 +31,58 @@
public class TestXMLDocumentReader extends BaseStandaloneTest
{
- DocumentReaderService service_;
+ DocumentReaderService service;
public void setUp() throws Exception
{
super.setUp();
- service_ = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
+ service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
}
public void testGetContentAsString() throws Exception
{
InputStream is = TestXMLDocumentReader.class.getResourceAsStream("/test.xml");
- String text = service_.getDocumentReader("text/xml").getContentAsText(is);
- String expected = "John\n" + " Alice\n" + " Reminder\n" + " Don't forget it this weekend!";
- assertEquals("Wrong string returned", expected, text.trim());
+ try
+ {
+ String text = service.getDocumentReader("text/xml").getContentAsText(is);
+ String expected = "John\n" + " Alice\n" + " Reminder\n" + " Don't forget it this weekend!";
+ assertEquals("Wrong string returned", expected, text.trim());
+ }
+ finally
+ {
+ is.close();
+ }
}
public void testCDATAGetContentAsString() throws Exception
{
InputStream is = TestXMLDocumentReader.class.getResourceAsStream("/testCDATA.xml");
- String text = service_.getDocumentReader("text/xml").getContentAsText(is);
- String expected = "This is a text inside CDATA.";
- assertEquals("Wrong string returned", expected, text.trim());
+ try
+ {
+ String text = service.getDocumentReader("text/xml").getContentAsText(is);
+ String expected = "This is a text inside CDATA.";
+ assertEquals("Wrong string returned", expected, text.trim());
+ }
+ finally
+ {
+ is.close();
+ }
}
public void testI18ngetContentAsString() throws Exception
{
InputStream is = TestXMLDocumentReader.class.getResourceAsStream("/testUTF8.xml");
- String text = service_.getDocumentReader("text/xml").getContentAsText(is);
- final String expected =
- "\u0426\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u0438\u0439 \u0442\u0435\u043a\u0441\u0442.\n"
- + "Archim\u00E8de et Lius \u00E0 Ch\u00E2teauneuf testing chars en \u00E9t\u00E9";
- assertEquals("Wrong string returned", expected, text.trim());
+ try
+ {
+ String text = service.getDocumentReader("text/xml").getContentAsText(is);
+ final String expected =
+ "\u0426\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u0438\u0439 \u0442\u0435\u043a\u0441\u0442.\n"
+ + "Archim\u00E8de et Lius \u00E0 Ch\u00E2teauneuf testing chars en \u00E9t\u00E9";
+ assertEquals("Wrong string returned", expected, text.trim());
+ }
+ finally
+ {
+ is.close();
+ }
}
-
}
13 years, 10 months
exo-jcr SVN: r2996 - in kernel/trunk/exo.kernel.commons/src: test/java/org/exoplatform/commons/utils and 1 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-08-27 03:03:02 -0400 (Fri, 27 Aug 2010)
New Revision: 2996
Modified:
kernel/trunk/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/MapResourceBundle.java
kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/TestMapResourceBundle.java
kernel/trunk/exo.kernel.commons/src/test/resources/org/exoplatform/commons/utils/resources.properties
Log:
EXOJCR-922: We use a call stack to check if a key has already been asked without being resolved
Other little improvements:
* The StringBuffer has been replaced with a StringBuilder
* The tempMap is initialized with the content of props to avoid resolving several time the same value of a given key
Modified: kernel/trunk/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/MapResourceBundle.java
===================================================================
--- kernel/trunk/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/MapResourceBundle.java 2010-08-26 15:30:31 UTC (rev 2995)
+++ kernel/trunk/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/MapResourceBundle.java 2010-08-27 07:03:02 UTC (rev 2996)
@@ -21,6 +21,7 @@
import java.io.Serializable;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
@@ -36,6 +37,11 @@
public class MapResourceBundle extends ResourceBundle implements Serializable
{
+ /**
+ * The serial version UID
+ */
+ private static final long serialVersionUID = -7020823660841958748L;
+
private final static String REGEXP = "#\\{.*\\}";
private Map props = new HashMap();
@@ -123,35 +129,42 @@
public void resolveDependencies()
{
- Map tempMap = new HashMap();
- Set keys = props.keySet();
+ Map tempMap = new HashMap(props);
+ Set keys = tempMap.keySet();
Pattern pattern = Pattern.compile(REGEXP);
for (Iterator iter = keys.iterator(); iter.hasNext();)
{
String element = (String)iter.next();
- String value = lookupKey(element, pattern);
+ String value = lookupKey(tempMap, element, pattern, new HashSet<String>());
tempMap.put(element, value);
}
props = tempMap;
}
- private String lookupKey(String key, Pattern pattern)
+ private String lookupKey(Map props, String key, Pattern pattern, Set<String> callStack)
{
String s = (String)props.get(key);
- if (s == null)
+ if (s == null || callStack.contains(key))
+ {
+ // The value cannot be found or it has already been asked which means that
+ // a loop has been detected
return key;
+ }
+ callStack.add(key);
Matcher matcher = pattern.matcher(s);
if (matcher.find())
{
- return recursivedResolving(s, pattern);
+ return recursivedResolving(props, s, pattern, callStack);
}
+ // The value could be resolved thus it can be removed from the callStack
+ callStack.remove(key);
return s;
}
- private String recursivedResolving(String key, Pattern pattern)
+ private String recursivedResolving(Map props, String value, Pattern pattern, Set<String> callStack)
{
- String resolved = key;
- StringBuffer sB = new StringBuffer();
+ String resolved = value;
+ StringBuilder sB = new StringBuilder();
while (resolved.indexOf("#{") != -1)
{
sB.setLength(0);
@@ -159,7 +172,7 @@
int lastIndex = resolved.indexOf('}', firstIndex);
String realKey = resolved.substring(firstIndex + 2, lastIndex);
sB.append(resolved.substring(0, firstIndex));
- sB.append(lookupKey(realKey, pattern));
+ sB.append(lookupKey(props, realKey, pattern, callStack));
sB.append(resolved.substring(lastIndex + 1));
resolved = sB.toString();
}
Modified: kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/TestMapResourceBundle.java
===================================================================
--- kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/TestMapResourceBundle.java 2010-08-26 15:30:31 UTC (rev 2995)
+++ kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/TestMapResourceBundle.java 2010-08-27 07:03:02 UTC (rev 2996)
@@ -33,9 +33,19 @@
ResourceBundle rB = ResourceBundle.getBundle("org.exoplatform.commons.utils.resources");
MapResourceBundle mapRB = new MapResourceBundle(rB, new Locale("en"));
mapRB.resolveDependencies();
- // System.out.println("KEYYYYYYYYY2 "+mapRB.getString("key1"));
- System.out.println("KEYYYYYYYYY2 " + mapRB.getString("key2"));
- // System.out.println("KEYYYYYYYYY2 "+mapRB.getString("key3"));
+ assertEquals("attention", mapRB.getString("key1"));
+ assertEquals("attention please", mapRB.getString("key3"));
+ assertEquals("attention and attention please alors", mapRB.getString("key2"));
+ assertEquals("non-existing", mapRB.getString("key4"));
+ assertEquals("key5 StackOverflowError", mapRB.getString("key5"));
+ assertTrue(mapRB.getString("key6").startsWith("key"));
+ assertTrue(mapRB.getString("key7").startsWith("key"));
+ assertEquals("some other value value", mapRB.getString("key8"));
+ assertEquals("other value", mapRB.getString("key9"));
+ assertEquals("value", mapRB.getString("key10"));
+ assertEquals("X", mapRB.getString("key11"));
+ assertEquals("-X-", mapRB.getString("key12"));
+ assertEquals("-X-", mapRB.getString("key13"));
+ assertEquals("--X--", mapRB.getString("key14"));
}
-
}
Modified: kernel/trunk/exo.kernel.commons/src/test/resources/org/exoplatform/commons/utils/resources.properties
===================================================================
--- kernel/trunk/exo.kernel.commons/src/test/resources/org/exoplatform/commons/utils/resources.properties 2010-08-26 15:30:31 UTC (rev 2995)
+++ kernel/trunk/exo.kernel.commons/src/test/resources/org/exoplatform/commons/utils/resources.properties 2010-08-27 07:03:02 UTC (rev 2996)
@@ -1,3 +1,14 @@
key1=attention
key2=#{key1} and #{key3} alors
-key3=#{key1} please
\ No newline at end of file
+key3=#{key1} please
+key4=#{non-existing}
+key5=#{key5} StackOverflowError
+key6=#{key7}
+key7=#{key6}
+key8=some #{key9} #{key10}
+key9=other #{key10}
+key10=value
+key11=X
+key12=-#{key11}-
+key13=-#{key11}-
+key14=-#{key13}-
\ No newline at end of file
13 years, 10 months
exo-jcr SVN: r2995 - in jcr/trunk/exo.jcr.component.ftp/src/test: java/org/exoplatform/services/ftp/usecases and 1 other directories.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-08-26 11:30:31 -0400 (Thu, 26 Aug 2010)
New Revision: 2995
Added:
jcr/trunk/exo.jcr.component.ftp/src/test/java/org/exoplatform/services/ftp/usecases/
jcr/trunk/exo.jcr.component.ftp/src/test/java/org/exoplatform/services/ftp/usecases/TestCopyBetweenWorkspaces.java
Modified:
jcr/trunk/exo.jcr.component.ftp/src/test/resources/conf/standalone/test-jcr-config.xml
Log:
EXOJCR-849: test created
Added: jcr/trunk/exo.jcr.component.ftp/src/test/java/org/exoplatform/services/ftp/usecases/TestCopyBetweenWorkspaces.java
===================================================================
--- jcr/trunk/exo.jcr.component.ftp/src/test/java/org/exoplatform/services/ftp/usecases/TestCopyBetweenWorkspaces.java (rev 0)
+++ jcr/trunk/exo.jcr.component.ftp/src/test/java/org/exoplatform/services/ftp/usecases/TestCopyBetweenWorkspaces.java 2010-08-26 15:30:31 UTC (rev 2995)
@@ -0,0 +1,61 @@
+/*
+ * 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.ftp.usecases;
+
+import org.exoplatform.services.ftp.BaseFtpTest;
+import org.exoplatform.services.ftp.FtpConst;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: TestCopyBetweenWorkspaces.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class TestCopyBetweenWorkspaces extends BaseFtpTest
+{
+
+ public void testCopyBetweenWorkspaces() throws Exception
+ {
+ String filename = "testCopy.txt";
+ String fileContent = "exo ftp test copy server test\n";
+ try
+ {
+ connect();
+ pwd();
+ cwd("ws");
+ pwd();
+ stor(fileContent.getBytes(), filename);
+ String retrieved = new String(retr(filename));
+ assertEquals(fileContent, retrieved);
+
+ // make move
+ sendCommand(FtpConst.Commands.CMD_RNFR + ' ' + filename);
+ String response = readResponse();
+ assertTrue("Must start with 350, but was [" + response + "]", response.startsWith("350 "));
+ sendCommand(FtpConst.Commands.CMD_RNTO + ' ' + "/ws2/" + filename);
+ response = readResponse();
+ assertTrue("Must start with 250, but was [" + response + "]", response.startsWith("250 "));
+
+ }
+ finally
+ {
+ disconnect();
+ }
+ }
+}
Modified: jcr/trunk/exo.jcr.component.ftp/src/test/resources/conf/standalone/test-jcr-config.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ftp/src/test/resources/conf/standalone/test-jcr-config.xml 2010-08-26 14:32:29 UTC (rev 2994)
+++ jcr/trunk/exo.jcr.component.ftp/src/test/resources/conf/standalone/test-jcr-config.xml 2010-08-26 15:30:31 UTC (rev 2995)
@@ -32,10 +32,7 @@
<property name="sourceName" value="jdbcjcr" />
<property name="dialect" value="generic" />
<!-- example of direct jdbc connection usage (without JNDI), see docs for details -->
- <!-- property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/portal" />
- <property name="username" value="sa" />
- <property name="password" value="" / -->
+
<property name="multi-db" value="false" />
<property name="update-storage" value="true" />
<property name="max-buffer-size" value="204800" />
@@ -50,18 +47,51 @@
</cache>
<query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
<properties>
- <property name="indexDir" value="target/temp/index" />
+ <property name="indexDir" value="target/temp/index/ws" />
</properties>
</query-handler>
<lock-manager>
<time-out>900000</time-out><!-- 15min -->
<persister class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
<properties>
- <property name="path" value="target/temp/lock" />
+ <property name="path" value="target/temp/lock/ws" />
</properties>
</persister>
</lock-manager>
</workspace>
+ <workspace name="ws2" auto-init-root-nodetype="nt:unstructured">
+ <!-- for system storage -->
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="sourceName" value="jdbcjcr" />
+ <property name="dialect" value="generic" />
+ <!-- example of direct jdbc connection usage (without JNDI), see docs for details -->
+ <property name="multi-db" value="false" />
+ <property name="update-storage" value="true" />
+ <property name="max-buffer-size" value="204800" />
+ <property name="swap-directory" value="target/temp/swap/ws2" />
+ </properties>
+ </container>
+ <cache enabled="true">
+ <properties>
+ <property name="maxSize" value="3000" />
+ <property name="liveTime" value="300" /><!-- 30 sec -->
+ </properties>
+ </cache>
+ <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="indexDir" value="target/temp/index/ws2" />
+ </properties>
+ </query-handler>
+ <lock-manager>
+ <time-out>900000</time-out><!-- 15min -->
+ <persister class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
+ <properties>
+ <property name="path" value="target/temp/lock/ws2" />
+ </properties>
+ </persister>
+ </lock-manager>
+ </workspace>
</workspaces>
</repository>
</repositories>
13 years, 10 months
exo-jcr SVN: r2994 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-08-26 10:32:29 -0400 (Thu, 26 Aug 2010)
New Revision: 2994
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/SystemViewImporter.java
Log:
EXOJCR-880 : Determine property is multi or single value from nodetype definition in import of version history was implemented.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/SystemViewImporter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/SystemViewImporter.java 2010-08-26 12:47:40 UTC (rev 2993)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/SystemViewImporter.java 2010-08-26 14:32:29 UTC (rev 2994)
@@ -381,20 +381,14 @@
}
catch (IllegalStateException e)
{
- log.error(e,e);
- System.exit(0);
throw new RepositoryException(e.getMessage(), e);
}
catch (IllegalNameException e)
{
- log.error(e,e);
- System.exit(0);
throw new RepositoryException(e.getMessage(), e);
}
catch (IOException e)
{
- log.error(e,e);
- System.exit(0);
throw new RepositoryException(e.getMessage(), e);
}
13 years, 10 months
exo-jcr SVN: r2993 - jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-08-26 08:47:40 -0400 (Thu, 26 Aug 2010)
New Revision: 2993
Modified:
jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdRnFr.java
jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdRnTo.java
Log:
EXOJCR-849: now RENAME_TO operation do ignores RENAME_FROM workspace name
Modified: jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdRnFr.java
===================================================================
--- jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdRnFr.java 2010-08-26 12:43:55 UTC (rev 2992)
+++ jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdRnFr.java 2010-08-26 12:47:40 UTC (rev 2993)
@@ -65,7 +65,7 @@
curSession.getItem(repoPath);
- clientSession().setPrevParamsEx(repoPath);
+ clientSession().setPrevParamsEx(resName);
reply(FtpConst.Replyes.REPLY_350);
return;
Modified: jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdRnTo.java
===================================================================
--- jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdRnTo.java 2010-08-26 12:43:55 UTC (rev 2992)
+++ jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdRnTo.java 2010-08-26 12:47:40 UTC (rev 2993)
@@ -25,6 +25,7 @@
import java.io.IOException;
import java.util.ArrayList;
+import javax.jcr.Item;
import javax.jcr.NoSuchWorkspaceException;
import javax.jcr.PathNotFoundException;
import javax.jcr.Session;
@@ -75,8 +76,25 @@
return;
}
- curSession.move(clientSession().getPrevParamsEx(), repoPath);
- curSession.save();
+ // now check does move executed on same workspace
+ ArrayList<String> prevParamPath = clientSession().getFullPath(clientSession().getPrevParamsEx());
+ String prevRepoPath = clientSession().getRepoPath(prevParamPath);
+ if (prevParamPath.get(0).equals(newPath.get(0)))
+ {
+ //its the same workspace
+ curSession.move(prevRepoPath, repoPath);
+ curSession.save();
+ }
+ else
+ {
+ // there is different workspaces operation
+ curSession.getWorkspace().copy(prevParamPath.get(0), prevRepoPath, repoPath);
+ // now remove source node
+ Session srcSession = clientSession().getSession(prevParamPath.get(0));
+ Item item = srcSession.getItem(prevRepoPath);
+ item.remove();
+ srcSession.save();
+ }
reply(String.format(FtpConst.Replyes.REPLY_250, FtpConst.Commands.CMD_RNTO));
return;
13 years, 10 months