Author: nzamosenchuk
Date: 2012-03-07 04:01:33 -0500 (Wed, 07 Mar 2012)
New Revision: 5825
Added:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCDataContainerConfig.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-ijdbc-jbc.xml
jcr/branches/1.15.x/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-ijdbc-jbc.xml
Removed:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java.orig
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java.orig
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/pom.xml
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLMultiDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLSingleDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OracleConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OraclePoolConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/IngresSQLDBInitializer.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/OracleDBInitializer.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/PgSQLDBInitializer.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/StorageDBInitializer.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2ConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2MultiDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2SingleDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/GenericCQConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MSSQLConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MSSQLMultiDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MSSQLSingleDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLMultiDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLSingleDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleMultiDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OraclePoolConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleSingleDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/PostgreConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/PostgreMultiDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/PostgreSingleDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SybaseConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SybaseMultiDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SybaseSingleDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializerHelper.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSVNodeDataOptimization.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/export/ExportWorkspaceSystemViewTest.java
Log:
EXOJCR-1775 : implementation of ISOLATED databse structure with isolated tablespace for
each workspace
Modified: jcr/branches/1.15.x/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/pom.xml 2012-03-06 15:56:19 UTC (rev 5824)
+++ jcr/branches/1.15.x/exo.jcr.component.core/pom.xml 2012-03-07 09:01:33 UTC (rev 5825)
@@ -980,6 +980,13 @@
</properties>
</profile>
<profile>
+ <id>ijdbc</id>
+ <properties>
+
<jcr.test.configuration.file>/conf/standalone/test-configuration-ijdbc-jbc.xml</jcr.test.configuration.file>
+ <properties.url.suffix>-sjdbc.properties</properties.url.suffix>
+ </properties>
+ </profile>
+ <profile>
<id>cluster</id>
<properties>
<jcr.test.configuration.file>/conf/standalone/cluster/test-configuration-jbc.xml</jcr.test.configuration.file>
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -26,8 +26,26 @@
* @author Gennady Azarenkov
* @version $Id: DBConstants.java 34801 2009-07-31 15:44:50Z dkatayev $
*/
+/**
+ * @author <a href="mailto:nzamosenchuk@exoplatform.com">Nikolay
Zamosenchuk</a>
+ * @version $Id: DBConstants.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+/**
+ * @author <a href="mailto:nzamosenchuk@exoplatform.com">Nikolay
Zamosenchuk</a>
+ * @version $Id: DBConstants.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
public class DBConstants extends DialectConstants
{
+ // ============================= Tables ============================
+
+ protected String JCR_ITEM;
+
+ protected String JCR_VALUE;
+
+ protected String JCR_REF;
+
// ======================== Error constants ========================
/**
* JCR_PK_ITEM.
@@ -73,6 +91,16 @@
* JCR_IDX_REF_PROPERTY.
*/
protected String JCR_IDX_REF_PROPERTY;
+
+ /**
+ * JCR_IDX_ITEM_N_ORDER_NUM
+ */
+ protected String JCR_IDX_ITEM_N_ORDER_NUM;
+
+ /**
+ * JCR_IDX_ITEM_PARENT_FK
+ */
+ protected String JCR_IDX_ITEM_PARENT_FK;
// ======================== SQL scripts ========================
/**
Deleted:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java.orig
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java.orig 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java.orig 2012-03-07
09:01:33 UTC (rev 5825)
@@ -1,280 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.storage.jdbc;
-
-import org.exoplatform.services.database.utils.DialectConstants;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * @author Gennady Azarenkov
- * @version $Id: DBConstants.java 34801 2009-07-31 15:44:50Z dkatayev $
- */
-public class DBConstants extends DialectConstants
-{
- // ======================== Error constants ========================
- /**
- * JCR_PK_ITEM.
- */
- protected String JCR_PK_ITEM;
-
- /**
- * JCR_FK_ITEM_PARENT.
- */
- protected String JCR_FK_ITEM_PARENT;
-
- /**
- * JCR_IDX_ITEM_PARENT.
- */
- protected String JCR_IDX_ITEM_PARENT;
-
- /**
- * JCR_IDX_ITEM_PARENT_ID.
- */
- protected String JCR_IDX_ITEM_PARENT_ID;
-
- /**
- * JCR_PK_VALUE.
- */
- protected String JCR_PK_VALUE;
-
- /**
- * JCR_FK_VALUE_PROPERTY.
- */
- protected String JCR_FK_VALUE_PROPERTY;
-
- /**
- * JCR_IDX_VALUE_PROPERTY.
- */
- protected String JCR_IDX_VALUE_PROPERTY;
-
- /**
- * JCR_PK_REF.
- */
- protected String JCR_PK_REF;
-
- /**
- * JCR_IDX_REF_PROPERTY.
- */
- protected String JCR_IDX_REF_PROPERTY;
-
- // ======================== SQL scripts ========================
- /**
- * FIND_ITEM_BY_ID.
- */
- protected String FIND_ITEM_BY_ID;
-
- /**
- * FIND_ITEM_BY_PATH.
- */
- protected String FIND_ITEM_BY_PATH;
-
- /**
- * FIND_ITEM_BY_NAME.
- */
- protected String FIND_ITEM_BY_NAME;
-
- /**
- * FIND_CHILD_PROPERTY_BY_PATH.
- */
- protected String FIND_CHILD_PROPERTY_BY_PATH;
-
- /**
- * FIND_PROPERTY_BY_NAME.
- */
- protected String FIND_PROPERTY_BY_NAME;
-
- /**
- * FIND_REFERENCES.
- */
- protected String FIND_REFERENCES;
-
- /**
- * FIND_VALUES_BY_PROPERTYID.
- */
- protected String FIND_VALUES_BY_PROPERTYID;
-
- /**
- * FIND_VALUE_BY_PROPERTYID_OREDERNUMB.
- */
- protected String FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID;
-
- /**
- * FIND_VALUE_BY_PROPERTYID_OREDERNUMB.
- */
- protected String FIND_VALUE_BY_PROPERTYID_OREDERNUMB;
-
- /**
- * FIND_NODES_BY_PARENTID.
- */
- protected String FIND_NODES_BY_PARENTID;
-
- /**
- * FIND_LAST_ORDER_NUMBER_BY_PARENTID.
- */
- protected String FIND_LAST_ORDER_NUMBER_BY_PARENTID;
-
- /**
- * FIND_NODES_COUNT_BY_PARENTID.
- */
- protected String FIND_NODES_COUNT_BY_PARENTID;
-
- /**
- * FIND_PROPERTIES_BY_PARENTID.
- */
- protected String FIND_PROPERTIES_BY_PARENTID;
-
- /**
- * FIND_LOWEST_PROPERTY_VERSIONS.
- */
- protected String FIND_LOWEST_PROPERTY_VERSIONS;
-
- /**
- * INSERT_NODE.
- */
- protected String INSERT_NODE;
-
- /**
- * INSERT_PROPERTY.
- */
- protected String INSERT_PROPERTY;
-
- /**
- * INSERT_VALUE.
- */
- protected String INSERT_VALUE;
-
- /**
- * INSERT_REF.
- */
- protected String INSERT_REF;
-
- /**
- * RENAME_NODE.
- */
- protected String RENAME_NODE;
-
- /**
- * UPDATE_NODE.
- */
- protected String UPDATE_NODE;
-
- /**
- * UPDATE_PROPERTY.
- */
- protected String UPDATE_PROPERTY;
-
- /**
- * DELETE_ITEM.
- */
- protected String DELETE_ITEM;
-
- /**
- * DELETE_VALUE.
- */
- protected String DELETE_VALUE;
-
- /**
- * DELETE_REF.
- */
- protected String DELETE_REF;
-
- /**
- * FIND_NODES.
- */
- protected String FIND_NODES_AND_PROPERTIES;
-
- /**
- * FIND_NODES_COUNT
- */
- protected String FIND_NODES_COUNT;
-
- // ======================== ITEMS table ========================
- /**
- * COLUMN_ID.
- */
- public static final String COLUMN_ID = "ID";
-
- /**
- * COLUMN_PARENTID.
- */
- public static final String COLUMN_PARENTID = "PARENT_ID";
-
- /**
- * COLUMN_NAME.
- */
- public static final String COLUMN_NAME = "NAME";
-
- /**
- * COLUMN_VERSION.
- */
- public static final String COLUMN_VERSION = "VERSION";
-
- /**
- * CONTAINER_NAME. Exists only for single-db.
- */
- public static final String CONTAINER_NAME = "CONTAINER_NAME";
-
- /**
- * COLUMN_CLASS.
- */
- public static final String COLUMN_CLASS = "I_CLASS";
-
- /**
- * COLUMN_INDEX.
- */
- public static final String COLUMN_INDEX = "I_INDEX";
-
- /**
- * COLUMN_NORDERNUM.
- */
- public static final String COLUMN_NORDERNUM = "N_ORDER_NUM";
-
- /**
- * COLUMN_PTYPE.
- */
- public static final String COLUMN_PTYPE = "P_TYPE";
-
- /**
- * COLUMN_PMULTIVALUED.
- */
- public static final String COLUMN_PMULTIVALUED = "P_MULTIVALUED";
-
- // VALUE table
- /**
- * PROPERTY_ID
- */
- public static final String COLUMN_VPROPERTY_ID = "PROPERTY_ID";
-
- /**
- * COLUMN_VDATA.
- */
- public static final String COLUMN_VDATA = "DATA";
-
- /**
- * COLUMN_VORDERNUM.
- */
- public static final String COLUMN_VORDERNUM = "ORDER_NUM";
-
- /**
- * COLUMN_VSTORAGE_DESC.
- */
- public static final String COLUMN_VSTORAGE_DESC = "STORAGE_DESC";
-
-}
Added:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCDataContainerConfig.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCDataContainerConfig.java
(rev 0)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCDataContainerConfig.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -0,0 +1,207 @@
+/*
+ * Copyright (C) 2003-2012 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.storage.jdbc;
+
+import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jdbc.DataSourceProvider;
+
+import java.io.File;
+
+/**
+ * Contains JDBCWorkspaceDataContainer-specific configuration
+ *
+ * Created by The eXo Platform SAS 1.03.2012.
+ *
+ * @author <a href="mailto:nzamosenchuk@exoplatform.com.ua">Nikolay
Zamosenchuk</a>
+ * @version $Id: JDBCDataContainerConfig.java 5024 2012-03-01 13:36:58Z nzasemochuk $
+ */
+public class JDBCDataContainerConfig
+{
+ public static enum DatabaseStructureType {
+ /**
+ * Each workspace has it's own database
+ */
+ MULTI {
+ @Override
+ public boolean isSingleDatabase()
+ {
+ return false;
+ }
+
+ @Override
+ public boolean isSimpleTable()
+ {
+ return true;
+ }
+ },
+ /**
+ * All workspaces from each repositories can be stored in a single database within
one set of
+ * tables.
+ */
+ SINGLE {
+ @Override
+ public boolean isSingleDatabase()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isSimpleTable()
+ {
+ return false;
+ }
+ },
+ /**
+ * "ISOLATED" database structure combines SINGLE and MULTI, by offering
workspace and repository
+ * storage isolation within one datasource using per-workspace table spaces. So
each workspace
+ * have it's own set of database tables, that are isolated from others.
+ */
+ ISOLATED {
+ @Override
+ public boolean isSingleDatabase()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isSimpleTable()
+ {
+ return true;
+ }
+ };
+
+ /**
+ * @return true if database structure type requires same database for workspaces
within one repository
+ */
+ public abstract boolean isSingleDatabase(); // TODO rename?
+
+ /**
+ * @return true if database structure type doesn't have CONTAINER_NAME field in
ITEM's table
+ */
+ public abstract boolean isSimpleTable(); // TODO rename?
+
+ }
+
+ /**
+ * Use additional connection to databse to check same name siblings
+ */
+ public boolean checkSNSNewConnection;
+
+ /**
+ * Container name
+ */
+ public String containerName;
+
+ /**
+ * Database dialect
+ */
+ public String dbDialect;
+
+ /**
+ * Database driver
+ */
+ public String dbDriver;
+
+ /**
+ * Database password
+ */
+ public String dbPassword;
+
+ /**
+ * Datasource name
+ */
+ public String dbSourceName;
+
+ /**
+ * Database URL
+ */
+ public String dbUrl;
+
+ /**
+ * Database username
+ */
+ public String dbUserName;
+
+ /**
+ * Data structure type, replaces deprecated multiDb
+ */
+ public JDBCDataContainerConfig.DatabaseStructureType dbStructureType;
+
+ /**
+ * Suffix used in tables names when isolated-databse structure used
+ */
+ public String dbTableSuffix;
+
+ /**
+ * Use {@link #dbStructureType}
+ */
+ @Deprecated
+ public boolean multiDb;
+
+ /**
+ * Datasource provider
+ */
+ public DataSourceProvider dsProvider;
+
+ /**
+ * If datasource is managed by outer container
+ */
+ public boolean isManaged;
+
+ /**
+ * Buffer size
+ */
+ public int maxBufferSize;
+
+ /**
+ * Version of persisted storage
+ */
+ public String storageVersion;
+
+ /**
+ * Tempfile cleaner
+ */
+ public FileCleaner swapCleaner;
+
+ /**
+ * Swap directory
+ */
+ public File swapDirectory;
+
+ /**
+ * Unique container name
+ */
+ public String uniqueName;
+
+ /**
+ * Some DataBases supports query hints, that may improve query performance.
+ * For default hints are enabled.
+ */
+ public boolean useQueryHints;
+
+ /**
+ * ValueStorage provier
+ */
+ public ValueStoragePluginProvider valueStorageProvider;
+
+ /**
+ * Path to SQL initialization scripts
+ */
+ public String initScriptPath;
+
+}
\ No newline at end of file
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -24,17 +24,7 @@
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.dataflow.persistent.PersistedNodeData;
import org.exoplatform.services.jcr.dataflow.persistent.PersistedPropertyData;
-import org.exoplatform.services.jcr.datamodel.IllegalACLException;
-import org.exoplatform.services.jcr.datamodel.IllegalNameException;
-import org.exoplatform.services.jcr.datamodel.InternalQName;
-import org.exoplatform.services.jcr.datamodel.ItemData;
-import org.exoplatform.services.jcr.datamodel.ItemType;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.NodeDataIndexing;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPath;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.datamodel.ValueData;
+import org.exoplatform.services.jcr.datamodel.*;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.itemfilters.QPathEntryFilter;
import org.exoplatform.services.jcr.impl.dataflow.persistent.ACLHolder;
@@ -44,11 +34,9 @@
import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
import org.exoplatform.services.jcr.impl.storage.value.ValueStorageNotFoundException;
import org.exoplatform.services.jcr.impl.storage.value.fs.operations.ValueFileIOHelper;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.impl.util.io.SwapFile;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.jcr.storage.value.ValueIOChannel;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -115,18 +103,10 @@
*/
public static final int I_CLASS_PROPERTY = 2;
- protected final ValueStoragePluginProvider valueStorageProvider;
+ protected final JDBCDataContainerConfig containerConfig;
- protected final int maxBufferSize;
-
- protected final File swapDirectory;
-
- protected final FileCleaner swapCleaner;
-
protected final Connection dbConnection;
- protected final String containerName;
-
protected final SQLExceptionHandler exceptionHandler;
protected final List<ValueIOChannel> valueChanges;
@@ -209,49 +189,94 @@
protected final boolean readOnly;
/**
- * JDBCStorageConnection constructor.
- *
- * @param dbConnection
- * JDBC connection
- * @param containerName
- * Workspace conatiner name
- * @param valueStorageProvider
- * External Value Storage provider
- * @param maxBufferSize
- * maximum buffer size (config)
- * @param swapDirectory
- * swap directory (config)
- * @param swapCleaner
- * swap cleaner (FileCleaner)
- * @throws SQLException
- * database error
- */
- protected JDBCStorageConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ * JDBCStorageConnection constructor.
+ *
+ * @param dbConnection
+ * JDBC connection, should be opened before
+ * @param readOnly
+ * boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerConfig
+ * Workspace Storage Container configuration
+ */
+ protected JDBCStorageConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- this.valueStorageProvider = valueStorageProvider;
-
- this.maxBufferSize = maxBufferSize;
- this.swapDirectory = swapDirectory;
- this.swapCleaner = swapCleaner;
- this.containerName = containerName;
-
this.dbConnection = dbConnection;
this.readOnly = readOnly;
+ this.containerConfig = containerConfig;
if (!readOnly && dbConnection.getAutoCommit())
{
dbConnection.setAutoCommit(false);
}
+ prepareEntityNames();
prepareQueries();
- this.exceptionHandler = new SQLExceptionHandler(containerName, this);
+ this.exceptionHandler = new SQLExceptionHandler(this.containerConfig.containerName,
this);
this.valueChanges = new ArrayList<ValueIOChannel>();
}
+ protected void prepareEntityNames()
+ {
+ switch (containerConfig.dbStructureType)
+ {
+ case MULTI :
+ JCR_ITEM = "JCR_MITEM";
+ JCR_VALUE = "JCR_MVALUE";
+ JCR_REF = "JCR_MREF";
+ JCR_PK_ITEM = "JCR_PK_MITEM";
+ JCR_FK_ITEM_PARENT = "JCR_FK_MITEM_PARENT";
+ JCR_IDX_ITEM_PARENT = "JCR_IDX_MITEM_PARENT";
+ JCR_IDX_ITEM_PARENT_ID = "JCR_IDX_MITEM_PARENT_ID";
+ JCR_PK_VALUE = "JCR_PK_MVALUE";
+ JCR_FK_VALUE_PROPERTY = "JCR_FK_MVALUE_PROPERTY";
+ JCR_IDX_VALUE_PROPERTY = "JCR_IDX_MVALUE_PROPERTY";
+ JCR_PK_REF = "JCR_PK_MREF";
+ JCR_IDX_REF_PROPERTY = "JCR_IDX_MREF_PROPERTY";
+ JCR_IDX_ITEM_N_ORDER_NUM = "JCR_IDX_MITEM_N_ORDER_NUM";
+ JCR_IDX_ITEM_PARENT_FK = "JCR_IDX_MITEM_PARENT_FK";
+ break;
+ case SINGLE :
+ JCR_ITEM = "JCR_SITEM";
+ JCR_VALUE = "JCR_SVALUE";
+ JCR_REF = "JCR_SREF";
+ JCR_PK_ITEM = "JCR_PK_SITEM";
+ JCR_FK_ITEM_PARENT = "JCR_FK_SITEM_PARENT";
+ JCR_IDX_ITEM_PARENT = "JCR_IDX_SITEM_PARENT";
+ JCR_IDX_ITEM_PARENT_ID = "JCR_IDX_SITEM_PARENT_ID";
+ JCR_PK_VALUE = "JCR_PK_SVALUE";
+ JCR_FK_VALUE_PROPERTY = "JCR_FK_SVALUE_PROPERTY";
+ JCR_IDX_VALUE_PROPERTY = "JCR_IDX_SVALUE_PROPERTY";
+ JCR_PK_REF = "JCR_PK_SREF";
+ JCR_IDX_REF_PROPERTY = "JCR_IDX_SREF_PROPERTY";
+ JCR_IDX_ITEM_N_ORDER_NUM = "JCR_IDX_SITEM_N_ORDER_NUM";
+ JCR_IDX_ITEM_PARENT_FK = "JCR_IDX_SITEM_PARENT_FK";
+ break;
+
+ case ISOLATED :
+ JCR_ITEM = "JCR_I" + containerConfig.dbTableSuffix;
+ JCR_VALUE = "JCR_V" + containerConfig.dbTableSuffix;
+ JCR_REF = "JCR_R" + containerConfig.dbTableSuffix;
+ JCR_PK_ITEM = "JCR_PK_I" + containerConfig.dbTableSuffix;
+ JCR_FK_ITEM_PARENT = "JCR_FK_I" + containerConfig.dbTableSuffix +
"_PARENT";
+ JCR_IDX_ITEM_PARENT = "JCR_IDX_I" + containerConfig.dbTableSuffix +
"_PARENT";
+ JCR_IDX_ITEM_PARENT_ID = "JCR_IDX_I" +
containerConfig.dbTableSuffix + "_PARENT_ID";
+ JCR_PK_VALUE = "JCR_PK_V" + containerConfig.dbTableSuffix;
+ JCR_FK_VALUE_PROPERTY = "JCR_FK_V" + containerConfig.dbTableSuffix
+ "_PROPERTY";
+ JCR_IDX_VALUE_PROPERTY = "JCR_IDX_V" +
containerConfig.dbTableSuffix + "_PROPERTY";
+ JCR_PK_REF = "JCR_PK_R" + containerConfig.dbTableSuffix;
+ JCR_IDX_REF_PROPERTY = "JCR_IDX_R" + containerConfig.dbTableSuffix
+ "_PROPERTY";
+ JCR_IDX_ITEM_N_ORDER_NUM = "JCR_IDX_I" +
containerConfig.dbTableSuffix + "_N_ORDER_NUM";
+ JCR_IDX_ITEM_PARENT_FK = "JCR_IDX_I" +
containerConfig.dbTableSuffix + "_PARENT_FK";
+ break;
+
+ default :
+ break;
+ }
+ }
+
/**
* {@inheritDoc}
*/
@@ -1342,7 +1367,7 @@
throw new RepositoryException(e);
}
}
-
+
/**
* {@inheritDoc}
*/
@@ -1437,8 +1462,8 @@
if (valueRecord.next())
{
String storageId = valueRecord.getString(COLUMN_VSTORAGE_DESC);
- return valueRecord.wasNull() ? readValueData(cid, orderNumb,
persistedVersion, valueRecord
- .getBinaryStream(COLUMN_VDATA)) : readValueData(propertyId, orderNumb,
storageId);
+ return valueRecord.wasNull() ? readValueData(cid, orderNumb,
persistedVersion,
+ valueRecord.getBinaryStream(COLUMN_VDATA)) : readValueData(propertyId,
orderNumb, storageId);
}
return null;
@@ -2147,7 +2172,7 @@
if (!ptProp.next())
{
throw new PrimaryTypeNotFoundException("FATAL ERROR primary type
record not found. Node "
- + qpath.getAsString() + ", id " + cid + ", container
" + this.containerName, null);
+ + qpath.getAsString() + ", id " + cid + ", container
" + this.containerConfig.containerName, null);
}
byte[] data = ptProp.getBytes(COLUMN_VDATA);
@@ -2171,8 +2196,8 @@
{
// use permissions from existed parent
acl =
- new AccessControlList(readACLOwner(cid), parentACL.hasPermissions()
? parentACL
- .getPermissionEntries() : null);
+ new AccessControlList(readACLOwner(cid), parentACL.hasPermissions()
+ ? parentACL.getPermissionEntries() : null);
}
else
{
@@ -2207,8 +2232,8 @@
{
// construct ACL from existed parent ACL
acl =
- new AccessControlList(parentACL.getOwner(),
parentACL.hasPermissions() ? parentACL
- .getPermissionEntries() : null);
+ new AccessControlList(parentACL.getOwner(),
parentACL.hasPermissions()
+ ? parentACL.getPermissionEntries() : null);
}
else
{
@@ -2326,7 +2351,7 @@
final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC);
if (!valueRecords.wasNull())
{
- final ValueIOChannel channel =
valueStorageProvider.getChannel(storageId);
+ final ValueIOChannel channel =
this.containerConfig.valueStorageProvider.getChannel(storageId);
try
{
channel.delete(pdata.getIdentifier());
@@ -2385,8 +2410,8 @@
final int orderNum = valueRecords.getInt(COLUMN_VORDERNUM);
final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC);
ValueData vdata =
- valueRecords.wasNull() ? readValueData(cid, orderNum, cversion,
valueRecords
- .getBinaryStream(COLUMN_VDATA)) : readValueData(identifier, orderNum,
storageId);
+ valueRecords.wasNull() ? readValueData(cid, orderNum, cversion,
+ valueRecords.getBinaryStream(COLUMN_VDATA)) : readValueData(identifier,
orderNum, storageId);
data.add(vdata);
}
}
@@ -2425,10 +2450,10 @@
protected ValueData readValueData(String identifier, int orderNumber, String
storageId) throws SQLException,
IOException, ValueStorageNotFoundException
{
- ValueIOChannel channel = valueStorageProvider.getChannel(storageId);
+ ValueIOChannel channel =
this.containerConfig.valueStorageProvider.getChannel(storageId);
try
{
- return channel.read(identifier, orderNumber, maxBufferSize);
+ return channel.read(identifier, orderNumber,
this.containerConfig.maxBufferSize);
}
finally
{
@@ -2476,11 +2501,11 @@
out.write(spoolBuffer, 0, read);
len += read;
}
- else if (len + read > maxBufferSize)
+ else if (len + read > this.containerConfig.maxBufferSize)
{
// threshold for keeping data in memory exceeded;
// create temp file and spool buffer contents
- swapFile = SwapFile.get(swapDirectory, cid + orderNumber +
"." + version);
+ swapFile = SwapFile.get(this.containerConfig.swapDirectory, cid +
orderNumber + "." + version);
if (swapFile.isSpooled())
{
// break, value already spooled
@@ -2516,7 +2541,7 @@
if (buffer == null)
{
- return new CleanableFilePersistedValueData(orderNumber, swapFile, swapCleaner);
+ return new CleanableFilePersistedValueData(orderNumber, swapFile,
this.containerConfig.swapCleaner);
}
return new ByteArrayPersistedValueData(orderNumber, buffer);
@@ -2540,7 +2565,7 @@
for (int i = 0; i < vdata.size(); i++)
{
ValueData vd = vdata.get(i);
- ValueIOChannel channel = valueStorageProvider.getApplicableChannel(data, i);
+ ValueIOChannel channel =
this.containerConfig.valueStorageProvider.getApplicableChannel(data, i);
InputStream stream;
int streamLength;
String storageId;
@@ -2557,7 +2582,8 @@
{
StreamPersistedValueData streamData = (StreamPersistedValueData)vd;
- SwapFile swapFile = SwapFile.get(swapDirectory, cid + i + "." +
data.getPersistedVersion());
+ SwapFile swapFile =
+ SwapFile.get(this.containerConfig.swapDirectory, cid + i +
"." + data.getPersistedVersion());
try
{
writeValueHelper.writeStreamedValue(swapFile, streamData);
Deleted:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java.orig
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java.orig 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java.orig 2012-03-07
09:01:33 UTC (rev 5825)
@@ -1,2806 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.storage.jdbc;
-
-import org.exoplatform.commons.utils.PrivilegedFileHelper;
-import org.exoplatform.services.jcr.access.AccessControlEntry;
-import org.exoplatform.services.jcr.access.AccessControlList;
-import org.exoplatform.services.jcr.dataflow.ItemState;
-import org.exoplatform.services.jcr.dataflow.persistent.PersistedNodeData;
-import org.exoplatform.services.jcr.dataflow.persistent.PersistedPropertyData;
-import org.exoplatform.services.jcr.datamodel.IllegalACLException;
-import org.exoplatform.services.jcr.datamodel.IllegalNameException;
-import org.exoplatform.services.jcr.datamodel.InternalQName;
-import org.exoplatform.services.jcr.datamodel.ItemData;
-import org.exoplatform.services.jcr.datamodel.ItemType;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.NodeDataIndexing;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPath;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.datamodel.ValueData;
-import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.core.itemfilters.QPathEntryFilter;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.ACLHolder;
-import
org.exoplatform.services.jcr.impl.dataflow.persistent.ByteArrayPersistedValueData;
-import
org.exoplatform.services.jcr.impl.dataflow.persistent.CleanableFilePersistedValueData;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.StreamPersistedValueData;
-import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
-import org.exoplatform.services.jcr.impl.storage.value.ValueStorageNotFoundException;
-import org.exoplatform.services.jcr.impl.storage.value.fs.operations.ValueFileIOHelper;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.impl.util.io.SwapFile;
-import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.jcr.storage.value.ValueIOChannel;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.UnsupportedRepositoryOperationException;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady
Azarenkov</a>
- * @version $Id: JDBCStorageConnection.java 34801 2009-07-31 15:44:50Z dkatayev $
- */
-public abstract class JDBCStorageConnection extends DBConstants implements
WorkspaceStorageConnection
-{
-
- /**
- * Helper.
- */
- protected class WriteValueHelper extends ValueFileIOHelper
- {
- /**
- * {@inheritDoc}
- */
- @Override
- public void writeStreamedValue(File file, ValueData value) throws IOException
- {
- super.writeStreamedValue(file, value);
- }
- }
-
- /**
- * Connection logger.
- */
- protected static final Log LOG =
ExoLogger.getLogger("exo.jcr.component.core.JDBCStorageConnection");
-
- /**
- * NODE type.
- */
- public static final int I_CLASS_NODE = 1;
-
- /**
- * PROPERTY type.
- */
- public static final int I_CLASS_PROPERTY = 2;
-
- protected final ValueStoragePluginProvider valueStorageProvider;
-
- protected final int maxBufferSize;
-
- protected final File swapDirectory;
-
- protected final FileCleaner swapCleaner;
-
- protected final Connection dbConnection;
-
- protected final String containerName;
-
- protected final SQLExceptionHandler exceptionHandler;
-
- protected final List<ValueIOChannel> valueChanges;
-
- protected final WriteValueHelper writeValueHelper = new WriteValueHelper();
-
- // All statements should be closed in closeStatements() method.
-
- protected PreparedStatement findItemById;
-
- protected PreparedStatement findItemByPath;
-
- protected PreparedStatement findItemByName;
-
- protected PreparedStatement findChildPropertyByPath;
-
- protected PreparedStatement findPropertyByName;
-
- protected PreparedStatement findDescendantNodes;
-
- protected PreparedStatement findDescendantProperties;
-
- protected PreparedStatement findReferences;
-
- protected PreparedStatement findValuesByPropertyId;
-
- protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
-
- protected PreparedStatement findValuesDataByPropertyId;
-
- protected PreparedStatement findValueByPropertyIdOrderNumber;
-
- protected PreparedStatement findNodesByParentId;
-
- protected PreparedStatement findLastOrderNumberByParentId;
-
- protected PreparedStatement findNodesCountByParentId;
-
- protected PreparedStatement findPropertiesByParentId;
-
- protected PreparedStatement findMaxPropertyVersions;
-
- protected PreparedStatement insertItem;
-
- protected PreparedStatement insertNode;
-
- protected PreparedStatement insertProperty;
-
- protected PreparedStatement insertReference;
-
- protected PreparedStatement insertValue;
-
- protected PreparedStatement updateItem;
-
- protected PreparedStatement updateItemPath;
-
- protected PreparedStatement updateNode;
-
- protected PreparedStatement updateProperty;
-
- protected PreparedStatement deleteItem;
-
- protected PreparedStatement deleteNode;
-
- protected PreparedStatement deleteProperty;
-
- protected PreparedStatement deleteReference;
-
- protected PreparedStatement deleteValue;
-
- protected PreparedStatement renameNode;
-
- protected PreparedStatement findNodesAndProperties;
-
- protected PreparedStatement findNodesCount;
-
- /**
- * Read-only flag, if true the connection is marked as READ-ONLY.
- */
- protected final boolean readOnly;
-
- /**
- * JDBCStorageConnection constructor.
- *
- * @param dbConnection
- * JDBC connection
- * @param containerName
- * Workspace conatiner name
- * @param valueStorageProvider
- * External Value Storage provider
- * @param maxBufferSize
- * maximum buffer size (config)
- * @param swapDirectory
- * swap directory (config)
- * @param swapCleaner
- * swap cleaner (FileCleaner)
- * @throws SQLException
- * database error
- */
- protected JDBCStorageConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
- throws SQLException
- {
-
- this.valueStorageProvider = valueStorageProvider;
-
- this.maxBufferSize = maxBufferSize;
- this.swapDirectory = swapDirectory;
- this.swapCleaner = swapCleaner;
- this.containerName = containerName;
-
- this.dbConnection = dbConnection;
- this.readOnly = readOnly;
-
- if (!readOnly && dbConnection.getAutoCommit())
- {
- dbConnection.setAutoCommit(false);
- }
-
- prepareQueries();
- this.exceptionHandler = new SQLExceptionHandler(containerName, this);
-
- this.valueChanges = new ArrayList<ValueIOChannel>();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof JDBCStorageConnection)
- {
- JDBCStorageConnection another = (JDBCStorageConnection)obj;
- return getJdbcConnection() == another.getJdbcConnection();
- }
-
- return false;
- }
-
- /**
- * Return JDBC connection obtained from initialized data source. NOTE: Helper can
obtain one new
- * connection per each call of the method or return one obtained once.
- */
- public Connection getJdbcConnection()
- {
- return dbConnection;
- }
-
- /**
- * Prepared queries at start time.
- *
- * @throws SQLException
- * database error
- */
- abstract protected void prepareQueries() throws SQLException;
-
- /**
- * Used in Single Db Connection classes for Identifier related queries.
- *
- * @param identifier
- * Item id
- * @return String with container internal id
- */
- protected abstract String getInternalId(String identifier);
-
- /**
- * Used in loadXYZRecord methods for extract real Identifier from container value.
- *
- * @param internalId
- * @return
- */
- protected abstract String getIdentifier(String internalId);
-
- // ---------------- WorkspaceStorageConnection -------------
-
- /**
- * @throws IllegalStateException
- * if connection is closed.
- */
- protected void checkIfOpened() throws IllegalStateException
- {
- if (!isOpened())
- {
- throw new IllegalStateException("Connection is closed");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isOpened()
- {
- try
- {
- return !dbConnection.isClosed();
- }
- catch (SQLException e)
- {
- LOG.error("An exception occured: " + e.getMessage());
- return false;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public final void rollback() throws IllegalStateException, RepositoryException
- {
- checkIfOpened();
- try
- {
- closeStatements();
-
- if (!readOnly)
- {
- dbConnection.rollback();
- }
-
- dbConnection.close();
-
- // rollback from the end
- for (int p = valueChanges.size() - 1; p >= 0; p--)
- {
- valueChanges.get(p).rollback();
- }
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- finally
- {
- valueChanges.clear();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public final void close() throws IllegalStateException, RepositoryException
- {
- checkIfOpened();
- try
- {
- closeStatements();
-
- if (!readOnly && dbConnection.getTransactionIsolation() >
Connection.TRANSACTION_READ_COMMITTED)
- {
- dbConnection.rollback();
- }
-
- dbConnection.close();
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * Close all statements.
- *
- * @throws SQLException
- */
- protected void closeStatements()
- {
- try
- {
- if (findItemById != null)
- {
- findItemById.close();
- }
-
- if (findItemByPath != null)
- {
- findItemByPath.close();
- }
-
- if (findItemByName != null)
- {
- findItemByName.close();
- }
-
- if (findChildPropertyByPath != null)
- {
- findChildPropertyByPath.close();
- }
-
- if (findPropertyByName != null)
- {
- findPropertyByName.close();
- }
-
- if (findDescendantNodes != null)
- {
- findDescendantNodes.close();
- }
-
- if (findDescendantProperties != null)
- {
- findDescendantProperties.close();
- }
-
- if (findReferences != null)
- {
- findReferences.close();
- }
-
- if (findValuesByPropertyId != null)
- {
- findValuesByPropertyId.close();
- }
-
- if (findValuesStorageDescriptorsByPropertyId != null)
- {
- findValuesStorageDescriptorsByPropertyId.close();
- }
-
- if (findValuesDataByPropertyId != null)
- {
- findValuesDataByPropertyId.close();
- }
-
- if (findValueByPropertyIdOrderNumber != null)
- {
- findValueByPropertyIdOrderNumber.close();
- }
-
- if (findNodesByParentId != null)
- {
- findNodesByParentId.close();
- }
-
- if (findLastOrderNumberByParentId != null)
- {
- findLastOrderNumberByParentId.close();
- }
-
- if (findNodesCountByParentId != null)
- {
- findNodesCountByParentId.close();
- }
-
- if (findPropertiesByParentId != null)
- {
- findPropertiesByParentId.close();
- }
-
- if (findMaxPropertyVersions != null)
- {
- findMaxPropertyVersions.close();
- }
-
- if (insertItem != null)
- {
- insertItem.close();
- }
-
- if (insertNode != null)
- {
- insertNode.close();
- }
-
- if (insertProperty != null)
- {
- insertProperty.close();
- }
-
- if (insertReference != null)
- {
- insertReference.close();
- }
-
- if (insertValue != null)
- {
- insertValue.close();
- }
-
- if (updateItem != null)
- {
- updateItem.close();
- }
-
- if (updateItemPath != null)
- {
- updateItemPath.close();
- }
-
- if (updateNode != null)
- {
- updateNode.close();
- }
-
- if (updateProperty != null)
- {
- updateProperty.close();
- }
-
- if (deleteItem != null)
- {
- deleteItem.close();
- }
-
- if (deleteNode != null)
- {
- deleteNode.close();
- }
-
- if (deleteProperty != null)
- {
- deleteProperty.close();
- }
-
- if (deleteReference != null)
- {
- deleteReference.close();
- }
-
- if (deleteValue != null)
- {
- deleteValue.close();
- }
-
- if (renameNode != null)
- {
- renameNode.close();
- }
-
- if (findNodesAndProperties != null)
- {
- findNodesAndProperties.close();
- }
-
- if (findNodesCount != null)
- {
- findNodesCount.close();
- }
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the statement: " + e.getMessage());
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public final void commit() throws IllegalStateException, RepositoryException
- {
- checkIfOpened();
- try
- {
- closeStatements();
-
- if (!this.readOnly)
- {
- dbConnection.commit();
- }
-
- dbConnection.close();
-
- try
- {
- for (ValueIOChannel vo : valueChanges)
- {
- vo.commit();
- }
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- finally
- {
- valueChanges.clear();
- }
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void add(NodeData data) throws RepositoryException,
UnsupportedOperationException, InvalidItemStateException,
- IllegalStateException
- {
- checkIfOpened();
- try
- {
- addNodeRecord(data);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Node added " + data.getQPath().getAsString() + ",
" + data.getIdentifier() + ", "
- + data.getPrimaryTypeName().getAsString());
- }
- }
- catch (SQLException e)
- {
- if (LOG.isDebugEnabled())
- {
- LOG.error("Node add. Database error: " + e);
- }
-
- exceptionHandler.handleAddException(e, data);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void add(PropertyData data) throws RepositoryException,
UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- checkIfOpened();
-
- try
- {
- addPropertyRecord(data);
-
- if (data.getType() == PropertyType.REFERENCE)
- {
- try
- {
- addReference(data);
- }
- catch (IOException e)
- {
- throw new RepositoryException("Can't read REFERENCE property
(" + data.getQPath() + " "
- + data.getIdentifier() + ") value: " + e.getMessage(), e);
- }
- }
-
- addValues(getInternalId(data.getIdentifier()), data);
-
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Property added " + data.getQPath().getAsString() +
", " + data.getIdentifier()
- + (data.getValues() != null ? ", values count: " +
data.getValues().size() : ", NULL data"));
- }
-
- }
- catch (IOException e)
- {
- if (LOG.isDebugEnabled())
- {
- LOG.error("Property add. IO error: " + e, e);
- }
- throw new RepositoryException("Error of Property Value add " + e, e);
- }
- catch (SQLException e)
- {
- if (LOG.isDebugEnabled())
- {
- LOG.error("Property add. Database error: " + e, e);
- }
- exceptionHandler.handleAddException(e, data);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void rename(NodeData data) throws RepositoryException,
UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
-
- checkIfOpened();
- try
- {
- if (renameNode(data) <= 0)
- {
- throw new JCRInvalidItemStateException("(rename) Node not found " +
data.getQPath().getAsString() + " "
- + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
- ItemState.RENAMED);
- }
- }
- catch (SQLException e)
- {
- if (LOG.isDebugEnabled())
- {
- LOG.error("Property add. Database error: " + e, e);
- }
- exceptionHandler.handleAddException(e, data);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void delete(NodeData data) throws RepositoryException,
UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- checkIfOpened();
-
- final String cid = getInternalId(data.getIdentifier());
-
- try
- {
- int nc = deleteItemByIdentifier(cid);
- if (nc <= 0)
- {
- throw new JCRInvalidItemStateException("(delete) Node not found " +
data.getQPath().getAsString() + " "
- + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
- ItemState.DELETED);
- }
-
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Node deleted " + data.getQPath().getAsString() + ",
" + data.getIdentifier() + ", "
- + (data).getPrimaryTypeName().getAsString());
- }
-
- }
- catch (SQLException e)
- {
- if (LOG.isDebugEnabled())
- {
- LOG.error("Node remove. Database error: " + e, e);
- }
- exceptionHandler.handleDeleteException(e, data);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void delete(PropertyData data) throws RepositoryException,
UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- checkIfOpened();
-
- final String cid = getInternalId(data.getIdentifier());
-
- try
- {
- deleteValues(cid, data, false);
-
- // delete references
- deleteReference(cid);
-
- // delete item
- int nc = deleteItemByIdentifier(cid);
- if (nc <= 0)
- {
- throw new JCRInvalidItemStateException("(delete) Property not found
" + data.getQPath().getAsString() + " "
- + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
- ItemState.DELETED);
- }
-
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Property deleted " + data.getQPath().getAsString() +
", " + data.getIdentifier()
- + ((data).getValues() != null ? ", values count: " +
(data).getValues().size() : ", NULL data"));
- }
-
- }
- catch (IOException e)
- {
- if (LOG.isDebugEnabled())
- {
- LOG.error("Property remove. IO error: " + e, e);
- }
- throw new RepositoryException("Error of Property Value delete " + e,
e);
- }
- catch (SQLException e)
- {
- if (LOG.isDebugEnabled())
- {
- LOG.error("Property remove. Database error: " + e, e);
- }
- exceptionHandler.handleDeleteException(e, data);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void update(NodeData data) throws RepositoryException,
UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- checkIfOpened();
- try
- {
- String cid = getInternalId(data.getIdentifier());
- // order numb update
- if (updateNodeByIdentifier(data.getPersistedVersion(),
data.getQPath().getIndex(), data.getOrderNumber(), cid) <= 0)
- {
- throw new JCRInvalidItemStateException("(update) Node not found " +
data.getQPath().getAsString() + " "
- + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
- ItemState.UPDATED);
- }
-
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Node updated " + data.getQPath().getAsString() + ",
" + data.getIdentifier() + ", "
- + data.getPrimaryTypeName().getAsString());
- }
-
- }
- catch (SQLException e)
- {
- if (LOG.isDebugEnabled())
- {
- LOG.error("Node update. Database error: " + e, e);
- }
- exceptionHandler.handleUpdateException(e, data);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void update(PropertyData data) throws RepositoryException,
UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- checkIfOpened();
-
- try
- {
- String cid = getInternalId(data.getIdentifier());
-
- // update type
- if (updatePropertyByIdentifier(data.getPersistedVersion(), data.getType(), cid)
<= 0)
- {
- throw new JCRInvalidItemStateException("(update) Property not found
" + data.getQPath().getAsString() + " "
- + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
- ItemState.UPDATED);
- }
-
- // update reference
- try
- {
- deleteReference(cid);
-
- if (data.getType() == PropertyType.REFERENCE)
- {
- addReference(data);
- }
- }
- catch (IOException e)
- {
- throw new RepositoryException("Can't update REFERENCE property
(" + data.getQPath() + " "
- + data.getIdentifier() + ") value: " + e.getMessage(), e);
- }
-
- // do Values update: delete all and add all
- deleteValues(cid, data, true);
- addValues(cid, data);
-
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Property updated " + data.getQPath().getAsString() +
", " + data.getIdentifier()
- + (data.getValues() != null ? ", values count: " +
data.getValues().size() : ", NULL data"));
- }
-
- }
- catch (IOException e)
- {
- if (LOG.isDebugEnabled())
- {
- LOG.error("Property update. IO error: " + e, e);
- }
- throw new RepositoryException("Error of Property Value update " + e,
e);
- }
- catch (SQLException e)
- {
- if (LOG.isDebugEnabled())
- {
- LOG.error("Property update. Database error: " + e, e);
- }
- exceptionHandler.handleUpdateException(e, data);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public List<NodeData> getChildNodesData(NodeData parent) throws
RepositoryException, IllegalStateException
- {
- checkIfOpened();
- try
- {
- ResultSet node =
findChildNodesByParentIdentifier(getInternalId(parent.getIdentifier()));
- try
- {
- List<NodeData> childrens = new ArrayList<NodeData>();
- while (node.next())
- {
- childrens.add((NodeData)itemData(parent.getQPath(), node, I_CLASS_NODE,
parent.getACL()));
- }
-
- return childrens;
- }
- finally
- {
- try
- {
- node.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e.getMessage());
- }
- }
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public List<NodeData> getChildNodesData(NodeData parent,
List<QPathEntryFilter> pattern) throws RepositoryException,
- IllegalStateException
- {
- //return all child nodes by default
- return getChildNodesData(parent);
- }
-
- /**
- * {@inheritDoc}
- */
- public int getLastOrderNumber(NodeData parent) throws RepositoryException
- {
- checkIfOpened();
- try
- {
- ResultSet count =
findLastOrderNumberByParentIdentifier(getInternalId(parent.getIdentifier()));
- try
- {
- if (count.next() && count.getInt(1) > 0)
- {
- return count.getInt(2);
- }
- else
- {
- return -1;
- }
- }
- finally
- {
- try
- {
- count.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e.getMessage());
- }
- }
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public int getMaxPropertyVersion(PropertyData data) throws RepositoryException
- {
- checkIfOpened();
- try
- {
- ResultSet count = findMaxPropertyVersion(data.getParentIdentifier(),
data.getQPath().getName().getAsString(), data.getQPath().getIndex());
- try
- {
- if (count.next())
- {
- return count.getInt(1);
- }
- else
- {
- return 0;
- }
- }
- finally
- {
- try
- {
- count.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e);
- }
- }
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public int getChildNodesCount(NodeData parent) throws RepositoryException
- {
- checkIfOpened();
- try
- {
- ResultSet count =
findChildNodesCountByParentIdentifier(getInternalId(parent.getIdentifier()));
- try
- {
- if (count.next())
- {
- return count.getInt(1);
- }
- else
- {
- throw new RepositoryException("FATAL No resulton childNodes count for
"
- + parent.getQPath().getAsString());
- }
- }
- finally
- {
- try
- {
- count.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e.getMessage());
- }
- }
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public List<PropertyData> getChildPropertiesData(NodeData parent) throws
RepositoryException, IllegalStateException
- {
- checkIfOpened();
- try
- {
- ResultSet prop =
findChildPropertiesByParentIdentifier(getInternalId(parent.getIdentifier()));
- try
- {
- List<PropertyData> children = new ArrayList<PropertyData>();
- while (prop.next())
- {
- children.add((PropertyData)itemData(parent.getQPath(), prop,
I_CLASS_PROPERTY, null));
- }
-
- return children;
- }
- finally
- {
- try
- {
- prop.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e.getMessage());
- }
- }
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public List<PropertyData> getChildPropertiesData(NodeData parent,
List<QPathEntryFilter> itemDataFilter)
- throws RepositoryException, IllegalStateException
- {
- //return all child properties by default
- return getChildPropertiesData(parent);
- }
-
- /**
- * Returns from storage the next page of nodes and its properties.
- */
- public List<NodeDataIndexing> getNodesAndProperties(String lastNodeId, int
offset, int limit)
- throws RepositoryException, IllegalStateException
- {
- List<NodeDataIndexing> result = new ArrayList<NodeDataIndexing>();
-
- checkIfOpened();
- try
- {
- ResultSet resultSet = findNodesAndProperties(lastNodeId, offset, limit);
- int processed = 0;
-
- try
- {
- TempNodeData tempNodeData = null;
-
- while (resultSet.next())
- {
- if (tempNodeData == null)
- {
- tempNodeData = new TempNodeData(resultSet);
- processed++;
- }
- else if (!resultSet.getString(COLUMN_ID).equals(tempNodeData.cid))
- {
- if (!needToSkipOffsetNodes() || processed > offset)
- {
- result.add(createNodeDataIndexing(tempNodeData));
- }
-
- tempNodeData = new TempNodeData(resultSet);
- processed++;
- }
-
- if (!needToSkipOffsetNodes() || processed > offset)
- {
- String key = resultSet.getString("P_NAME");
-
- SortedSet<TempPropertyData> values =
tempNodeData.properties.get(key);
- if (values == null)
- {
- values = new TreeSet<TempPropertyData>();
- tempNodeData.properties.put(key, values);
- }
-
- values.add(new ExtendedTempPropertyData(resultSet));
- }
- }
-
- if (tempNodeData != null && (!needToSkipOffsetNodes() || processed
> offset))
- {
- result.add(createNodeDataIndexing(tempNodeData));
- }
- }
- finally
- {
- try
- {
- resultSet.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e.getMessage());
- }
- }
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- catch (IllegalNameException e)
- {
- throw new RepositoryException(e);
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
-
- return result;
- }
-
- /**
- * Some implementations could require to skip first 'offset' nodes from
- * result set.
- */
- protected boolean needToSkipOffsetNodes()
- {
- return false;
- }
-
- /**
- *
- * @param parent
- * @param lastOrderNum
- * @param limit
- * @return
- * @throws RepositoryException
- * @throws IllegalStateException
- */
- public boolean getChildNodesDataByPage(NodeData parent, int fromOrderNum, int
toOrderNum, List<NodeData> childNodes)
- throws RepositoryException, IllegalStateException
- {
- // not supported by non-CQ deprecated JDBC container
- throw new UnsupportedRepositoryOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- public List<PropertyData> listChildPropertiesData(NodeData parent) throws
RepositoryException, IllegalStateException
- {
- checkIfOpened();
- try
- {
- ResultSet prop =
findChildPropertiesByParentIdentifier(getInternalId(parent.getIdentifier()));
- try
- {
- List<PropertyData> children = new ArrayList<PropertyData>();
- while (prop.next())
- {
- children.add(propertyData(parent.getQPath(), prop));
- }
-
- return children;
- }
- finally
- {
- try
- {
- prop.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e.getMessage());
- }
- }
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public List<ACLHolder> getACLHolders() throws RepositoryException,
IllegalStateException,
- UnsupportedOperationException
- {
- throw new UnsupportedOperationException(
- "This method is not supported by the old JDBCWorkspaceDataContainer, use
CQJDBCWorkspaceDataContainer instead.");
- }
-
- /**
- * {@inheritDoc}
- */
- public ItemData getItemData(String identifier) throws RepositoryException,
IllegalStateException
- {
- return getItemByIdentifier(getInternalId(identifier));
- }
-
- /**
- * {@inheritDoc}
- */
- public ItemData getItemData(NodeData parentData, QPathEntry name, ItemType itemType)
throws RepositoryException,
- IllegalStateException
- {
-
- if (parentData != null)
- {
- return getItemByName(parentData, getInternalId(parentData.getIdentifier()),
name, itemType);
- }
-
- // it's a root node
- return getItemByName(null, null, name, itemType);
- }
-
- /**
- * {@inheritDoc}
- */
- public List<PropertyData> getReferencesData(String nodeIdentifier) throws
RepositoryException, IllegalStateException
- {
- checkIfOpened();
- try
- {
- ResultSet refProps = findReferences(getInternalId(nodeIdentifier));
- try
- {
- List<PropertyData> references = new ArrayList<PropertyData>();
- while (refProps.next())
- {
- references.add((PropertyData)itemData(null, refProps, I_CLASS_PROPERTY,
null));
- }
- return references;
- }
- finally
- {
- try
- {
- refProps.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e.getMessage());
- }
- }
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * Reads Property Value from persistent storage.
- *
- * @param propertyId String, Property id
- * @param orderNumb int, Value order number (in list of values)
- * @param persistedVersion int
- * @return ValueData
- * @throws RepositoryException if read error occurs
- */
- public ValueData getValue(String propertyId, int orderNumb, int persistedVersion)
throws RepositoryException
- {
- try
- {
- String cid = getInternalId(propertyId);
- ResultSet valueRecord = findValueByPropertyIdOrderNumber(cid, orderNumb);
- try
- {
- if (valueRecord.next())
- {
- String storageId = valueRecord.getString(COLUMN_VSTORAGE_DESC);
- return valueRecord.wasNull() ? readValueData(cid, orderNumb,
persistedVersion, valueRecord
- .getBinaryStream(COLUMN_VDATA)) : readValueData(propertyId, orderNumb,
storageId);
- }
-
- return null;
- }
- finally
- {
- try
- {
- valueRecord.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet ", e);
- }
- }
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * Reads count of nodes in workspace.
- *
- * @return
- * nodes count
- * @throws RepositoryException
- * if a database access error occurs
- */
- public long getNodesCount() throws RepositoryException
- {
- ResultSet countNodes;
- try
- {
- countNodes = findNodesCount();
- if (countNodes.next())
- {
- return countNodes.getLong(1);
- }
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
-
- throw new RepositoryException("Can not calculate nodes count");
- }
-
- // ------------------ Private methods ---------------
-
- /**
- * Get Item By Identifier.
- *
- * @param cid
- * Item id (container internal)
- * @return ItemData
- * @throws RepositoryException
- * Repository error
- * @throws IllegalStateException
- * if connection is closed
- */
- protected ItemData getItemByIdentifier(String cid) throws RepositoryException,
IllegalStateException
- {
- checkIfOpened();
- try
- {
- ResultSet item = findItemByIdentifier(cid);
- try
- {
- if (item.next())
- {
- return itemData(null, item, item.getInt(COLUMN_CLASS), null);
- }
- return null;
- }
- finally
- {
- try
- {
- item.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e.getMessage());
- }
- }
- }
- catch (SQLException e)
- {
- throw new RepositoryException("getItemData() error", e);
- }
- catch (IOException e)
- {
- throw new RepositoryException("getItemData() error", e);
- }
- }
-
- /**
- * Gets an item data from database.
- *
- * @param parentPath
- * - parent QPath
- * @param parentId
- * - parent container internal id (depends on Multi/Single DB)
- * @param name
- * - item name
- * @param itemType
- * - item type
- * @return - ItemData instance
- * @throws RepositoryException
- * Repository error
- * @throws IllegalStateException
- * if connection is closed
- */
- protected ItemData getItemByName(NodeData parent, String parentId, QPathEntry name,
ItemType itemType)
- throws RepositoryException, IllegalStateException
- {
- checkIfOpened();
- try
- {
- ResultSet item = null;
- try
- {
- item = findItemByName(parentId, name.getAsString(), name.getIndex());
- while (item.next())
- {
- int columnClass = item.getInt(COLUMN_CLASS);
- if (itemType == ItemType.UNKNOWN || columnClass == itemType.ordinal())
- {
- return itemData(parent.getQPath(), item, columnClass,
parent.getACL());
- }
- }
-
- return null;
- }
- finally
- {
- try
- {
- if (item != null)
- {
- item.close();
- }
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e.getMessage());
- }
- }
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * Build Item path by id.
- *
- * @param cpid
- * - Item id (container id)
- * @return Item QPath
- * @throws SQLException
- * - if database error occurs
- * @throws InvalidItemStateException
- * - if parent not found
- * @throws IllegalNameException
- * - if name on the path is wrong
- */
- protected QPath traverseQPath(String cpid) throws SQLException,
InvalidItemStateException, IllegalNameException
- {
- return traverseQPathSQ(cpid);
- }
-
- /**
- * The method <code>traverseQPath</code> implemented thanks to simple
queries. It allows
- * to use Simple Queries instead of Complex Queries when complex queries are much
slower such
- * as with HSQLDB for example.
- */
- protected QPath traverseQPathSQ(String cpid) throws SQLException,
InvalidItemStateException, IllegalNameException
- {
- // get item by Identifier usecase
- List<QPathEntry> qrpath = new ArrayList<QPathEntry>(); // reverted
path
- String caid = cpid; // container ancestor id
- do
- {
- ResultSet parent = findItemByIdentifier(caid);
- try
- {
- if (!parent.next())
- {
- throw new InvalidItemStateException("Parent not found, uuid: " +
getIdentifier(caid));
- }
-
- QPathEntry qpe =
- new QPathEntry(InternalQName.parse(parent.getString(COLUMN_NAME)),
parent.getInt(COLUMN_INDEX), caid);
- qrpath.add(qpe);
- caid = parent.getString(COLUMN_PARENTID);
- }
- finally
- {
- try
- {
- parent.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e.getMessage());
- }
- }
- }
- while (!caid.equals(Constants.ROOT_PARENT_UUID));
-
- QPathEntry[] qentries = new QPathEntry[qrpath.size()];
- int qi = 0;
- for (int i = qrpath.size() - 1; i >= 0; i--)
- {
- qentries[qi++] = qrpath.get(i);
- }
- return new QPath(qentries);
- }
-
- /**
- * ItemLocationInfo.
- *
- */
- class ItemLocationInfo
- {
- /**
- * Item qpath
- */
- final QPath qpath;
-
- /**
- * All ancestors of the item with qpath
- */
- final List<String> ancestors;
-
- /**
- * Item id.
- */
- final String itemId;
-
- /**
- * ItemLocationInfo constructor.
- *
- * @param qpath
- * Item path
- * @param ancestors
- * ancesstors id list
- * @param itemId
- * Item id
- */
- ItemLocationInfo(QPath qpath, List<String> ancestors, String itemId)
- {
- this.qpath = qpath;
- this.ancestors = ancestors;
- this.itemId = itemId;
- }
- }
-
- protected String findParentId(String cid) throws SQLException, RepositoryException
- {
- ResultSet pidrs = findItemByIdentifier(cid);
- try
- {
- if (pidrs.next())
- {
- return pidrs.getString(COLUMN_PARENTID);
- }
- else
- {
- throw new RepositoryException("Item not found id: " +
getIdentifier(cid));
- }
- }
- finally
- {
- try
- {
- pidrs.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e.getMessage());
- }
- }
- }
-
- /**
- * Build ItemData.
- *
- * @param parentPath
- * - parent path
- * @param item
- * database - ResultSet with Item record(s)
- * @param itemClass
- * - Item type (Node or Property)
- * @param parentACL
- * - parent ACL
- * @return ItemData instance
- * @throws RepositoryException
- * Repository error
- * @throws SQLException
- * database error
- * @throws IOException
- * I/O error
- */
- private ItemData itemData(QPath parentPath, ResultSet item, int itemClass,
AccessControlList parentACL)
- throws RepositoryException, SQLException, IOException
- {
- String cid = item.getString(COLUMN_ID);
- String cname = item.getString(COLUMN_NAME);
- int cversion = item.getInt(COLUMN_VERSION);
-
- String cpid = item.getString(COLUMN_PARENTID);
- // if parent ID is empty string - it's a root node
- // cpid = cpid.equals(Constants.ROOT_PARENT_UUID) ? null : cpid;
-
- try
- {
- if (itemClass == I_CLASS_NODE)
- {
- int cindex = item.getInt(COLUMN_INDEX);
- int cnordernumb = item.getInt(COLUMN_NORDERNUM);
- return loadNodeRecord(parentPath, cname, cid, cpid, cindex, cversion,
cnordernumb, parentACL);
- }
-
- int cptype = item.getInt(COLUMN_PTYPE);
- boolean cpmultivalued = item.getBoolean(COLUMN_PMULTIVALUED);
- return loadPropertyRecord(parentPath, cname, cid, cpid, cversion, cptype,
cpmultivalued);
- }
- catch (InvalidItemStateException e)
- {
- throw new InvalidItemStateException("FATAL: Can't build item path for
name " + cname + " id: "
- + getIdentifier(cid) + ". " + e);
- }
- }
-
- /**
- * Read property data without value data. For listChildPropertiesData(NodeData).
- *
- * @param parentPath
- * - parent path
- * @param item
- * database - ResultSet with Item record(s)
- * @return PropertyData instance
- * @throws RepositoryException
- * Repository error
- * @throws SQLException
- * database error
- * @throws IOException
- * I/O error
- */
- private PropertyData propertyData(QPath parentPath, ResultSet item) throws
RepositoryException, SQLException,
- IOException
- {
- String cid = item.getString(COLUMN_ID);
- String cname = item.getString(COLUMN_NAME);
- int cversion = item.getInt(COLUMN_VERSION);
- String cpid = item.getString(COLUMN_PARENTID);
- int cptype = item.getInt(COLUMN_PTYPE);
- boolean cpmultivalued = item.getBoolean(COLUMN_PMULTIVALUED);
-
- try
- {
- InternalQName qname = InternalQName.parse(cname);
-
- QPath qpath = QPath.makeChildPath(parentPath == null ? traverseQPath(cpid) :
parentPath, qname);
-
- PersistedPropertyData pdata =
- new PersistedPropertyData(getIdentifier(cid), qpath, getIdentifier(cpid),
cversion, cptype, cpmultivalued,
- new ArrayList<ValueData>());
-
- return pdata;
- }
- catch (InvalidItemStateException e)
- {
- throw new InvalidItemStateException("FATAL: Can't build property path
for name " + cname + " id: "
- + getIdentifier(cid) + ". " + e);
- }
- catch (IllegalNameException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * Mixin types description (internal use).
- *
- */
- public class MixinInfo
- {
-
- /**
- * OWNEABLE constant.
- */
- static final int OWNEABLE = 0x0001; // bits 0001
-
- /**
- * PRIVILEGEABLE constant.
- */
- static final int PRIVILEGEABLE = 0x0002; // bits 0010
-
- /**
- * OWNEABLE_PRIVILEGEABLE constant.
- */
- static final int OWNEABLE_PRIVILEGEABLE = OWNEABLE | PRIVILEGEABLE; // bits 0011
-
- /**
- * Mixin types.
- */
- final List<InternalQName> mixinTypes;
-
- /**
- * oexo:owneable flag.
- */
- final boolean owneable;
-
- /**
- * exo:privilegeable flag.
- */
- final boolean privilegeable;
-
- /**
- * Parent Id.
- */
- final String parentId = null;
-
- /**
- * MixinInfo constructor.
- *
- * @param mixinTypes
- * mixin types
- * @param owneable
- * exo:owneable flag
- * @param privilegeable
- * exo:privilegeable flag
- */
- public MixinInfo(List<InternalQName> mixinTypes, boolean owneable, boolean
privilegeable)
- {
- this.mixinTypes = mixinTypes;
- this.owneable = owneable;
- this.privilegeable = privilegeable;
- }
-
- /**
- * Return Mixin names array.
- *
- * @return InternalQName[] Mixin names array
- */
- public InternalQName[] mixinNames()
- {
- if (mixinTypes != null)
- {
- InternalQName[] mns = new InternalQName[mixinTypes.size()];
- mixinTypes.toArray(mns);
- return mns;
- }
- else
- {
- return new InternalQName[0];
- }
- }
-
- /**
- * Tell is exo:privilegeable.
- *
- * @return boolean
- */
- public boolean hasPrivilegeable()
- {
- return privilegeable;
- }
-
- /**
- * Tell is exo:owneable.
- *
- * @return boolean
- */
- public boolean hasOwneable()
- {
- return owneable;
- }
-
- public String getParentId()
- {
- return parentId;
- }
- }
-
- /**
- * Read mixins from database.
- *
- * @param cid
- * - Item id (internal)
- * @return MixinInfo
- * @throws SQLException
- * database error
- * @throws IllegalNameException
- * if nodetype name in mixin record is wrong
- */
- protected MixinInfo readMixins(String cid) throws SQLException, IllegalNameException
- {
- ResultSet mtrs = findPropertyByName(cid, Constants.JCR_MIXINTYPES.getAsString());
-
- try
- {
- List<InternalQName> mts = null;
- boolean owneable = false;
- boolean privilegeable = false;
- if (mtrs.next())
- {
- mts = new ArrayList<InternalQName>();
- do
- {
- byte[] mxnb = mtrs.getBytes(COLUMN_VDATA);
- if (mxnb != null)
- {
- InternalQName mxn = InternalQName.parse(new String(mxnb));
- mts.add(mxn);
-
- if (!privilegeable && Constants.EXO_PRIVILEGEABLE.equals(mxn))
- {
- privilegeable = true;
- }
- else if (!owneable && Constants.EXO_OWNEABLE.equals(mxn))
- {
- owneable = true;
- }
- } // else, if SQL NULL - skip it
- }
- while (mtrs.next());
- }
-
- return new MixinInfo(mts, owneable, privilegeable);
- }
- finally
- {
- try
- {
- mtrs.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e.getMessage());
- }
- }
- }
-
- /**
- * Return permission values or throw an exception. We assume the node is
mix:privilegeable.
- *
- * @param cid
- * Node id
- * @return list of ACL entries
- * @throws SQLException
- * database error
- * @throws IllegalACLException
- * if property exo:permissions is not found for node
- */
- protected List<AccessControlEntry> readACLPermisions(String cid) throws
SQLException, IllegalACLException
- {
- List<AccessControlEntry> naPermissions = new
ArrayList<AccessControlEntry>();
- ResultSet exoPerm = findPropertyByName(cid,
Constants.EXO_PERMISSIONS.getAsString());
- try
- {
- if (exoPerm.next())
- {
- do
- {
- StringTokenizer parser =
- new StringTokenizer(new String(exoPerm.getBytes(COLUMN_VDATA)),
AccessControlEntry.DELIMITER);
- naPermissions.add(new AccessControlEntry(parser.nextToken(),
parser.nextToken()));
- }
- while (exoPerm.next());
-
- return naPermissions;
- }
- else
- {
- throw new IllegalACLException("Property exo:permissions is not found for
node with id: "
- + getIdentifier(cid));
- }
- }
- finally
- {
- try
- {
- exoPerm.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e.getMessage());
- }
- }
- }
-
- /**
- * Return owner value or throw an exception. We assume the node is mix:owneable.
- *
- * @param cid
- * Node id
- * @return ACL owner
- * @throws SQLException
- * database error
- * @throws IllegalACLException
- * Property exo:owner is not found for node
- */
- protected String readACLOwner(String cid) throws SQLException, IllegalACLException
- {
- ResultSet exoOwner = findPropertyByName(cid, Constants.EXO_OWNER.getAsString());
- try
- {
- if (exoOwner.next())
- {
- return new String(exoOwner.getBytes(COLUMN_VDATA));
- }
- else
- {
- throw new IllegalACLException("Property exo:owner is not found for node
with id: " + getIdentifier(cid));
- }
- }
- finally
- {
- try
- {
- exoOwner.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e.getMessage());
- }
- }
- }
-
- /**
- * Load NodeData record.
- *
- * @param parentPath
- * parent path
- * @param cname
- * Node name
- * @param cid
- * Node id
- * @param cpid
- * Node parent id
- * @param cindex
- * Node index
- * @param cversion
- * Node persistent version
- * @param cnordernumb
- * Node order number
- * @param parentACL
- * Node parent ACL
- * @return PersistedNodeData
- * @throws RepositoryException
- * Repository error
- * @throws SQLException
- * database error
- */
- protected PersistedNodeData loadNodeRecord(QPath parentPath, String cname, String cid,
String cpid, int cindex,
- int cversion, int cnordernumb, AccessControlList parentACL) throws
RepositoryException, SQLException
- {
- try
- {
- InternalQName qname = InternalQName.parse(cname);
-
- QPath qpath;
- String parentCid;
- if (parentPath != null)
- {
- // get by parent and name
- qpath = QPath.makeChildPath(parentPath, qname, cindex, cid);
- parentCid = cpid;
- }
- else
- {
- // get by id
- if (cpid.equals(Constants.ROOT_PARENT_UUID))
- {
- // root node
- qpath = Constants.ROOT_PATH;
- parentCid = null;
- }
- else
- {
- qpath = QPath.makeChildPath(traverseQPath(cpid), qname, cindex, cid);
- parentCid = cpid;
- }
- }
-
- // PRIMARY
- ResultSet ptProp = findPropertyByName(cid,
Constants.JCR_PRIMARYTYPE.getAsString());
- try
- {
-
- if (!ptProp.next())
- {
- throw new PrimaryTypeNotFoundException("FATAL ERROR primary type
record not found. Node "
- + qpath.getAsString() + ", id " + cid + ", container
" + this.containerName, null);
- }
-
- byte[] data = ptProp.getBytes(COLUMN_VDATA);
- InternalQName ptName = InternalQName.parse(new String((data != null ? data :
new byte[]{})));
-
- // MIXIN
- MixinInfo mixins = readMixins(cid);
-
- // ACL
- AccessControlList acl; // NO DEFAULT values!
-
- if (mixins.hasOwneable())
- {
- // has own owner
- if (mixins.hasPrivilegeable())
- {
- // and permissions
- acl = new AccessControlList(readACLOwner(cid),
readACLPermisions(cid));
- }
- else if (parentACL != null)
- {
- // use permissions from existed parent
- acl =
- new AccessControlList(readACLOwner(cid), parentACL.hasPermissions()
? parentACL
- .getPermissionEntries() : null);
- }
- else
- {
- // have to search nearest ancestor permissions in ACL manager
- // acl = new AccessControlList(readACLOwner(cid),
traverseACLPermissions(cpid));
- acl = new AccessControlList(readACLOwner(cid), null);
- }
- }
- else if (mixins.hasPrivilegeable())
- {
- // has own permissions
- if (mixins.hasOwneable())
- {
- // and owner
- acl = new AccessControlList(readACLOwner(cid),
readACLPermisions(cid));
- }
- else if (parentACL != null)
- {
- // use owner from existed parent
- acl = new AccessControlList(parentACL.getOwner(),
readACLPermisions(cid));
- }
- else
- {
- // have to search nearest ancestor owner in ACL manager
- // acl = new AccessControlList(traverseACLOwner(cpid),
readACLPermisions(cid));
- acl = new AccessControlList(null, readACLPermisions(cid));
- }
- }
- else
- {
- if (parentACL != null)
- {
- // construct ACL from existed parent ACL
- acl =
- new AccessControlList(parentACL.getOwner(),
parentACL.hasPermissions() ? parentACL
- .getPermissionEntries() : null);
- }
- else
- {
- // have to search nearest ancestor owner and permissions in ACL
manager
- // acl = traverseACL(cpid);
- acl = null;
- }
- }
-
- return new PersistedNodeData(getIdentifier(cid), qpath,
getIdentifier(parentCid), cversion, cnordernumb,
- ptName, mixins.mixinNames(), acl);
- }
- catch (IllegalACLException e)
- {
- throw new RepositoryException("FATAL ERROR Node " +
getIdentifier(cid) + " " + qpath.getAsString()
- + " has wrong formed ACL. ", e);
- }
- finally
- {
- try
- {
- ptProp.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e.getMessage());
- }
- }
- }
- catch (IllegalNameException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * Load PropertyData record.
- *
- * @param parentPath
- * parent path
- * @param cname
- * Property name
- * @param cid
- * Property id
- * @param cpid
- * Property parent id
- * @param cversion
- * Property persistent verison
- * @param cptype
- * Property type
- * @param cpmultivalued
- * Property multivalued status
- * @return PersistedPropertyData
- * @throws RepositoryException
- * Repository error
- * @throws SQLException
- * database error
- * @throws IOException
- * I/O error
- */
- protected PersistedPropertyData loadPropertyRecord(QPath parentPath, String cname,
String cid, String cpid,
- int cversion, int cptype, boolean cpmultivalued) throws RepositoryException,
SQLException, IOException
- {
-
- // NOTE: cpid never should be null or root parent (' ')
-
- try
- {
- QPath qpath =
- QPath.makeChildPath(parentPath == null ? traverseQPath(cpid) : parentPath,
InternalQName.parse(cname));
-
- String identifier = getIdentifier(cid);
- List<ValueData> values = readValues(cid, identifier, cversion);
- PersistedPropertyData pdata =
- new PersistedPropertyData(identifier, qpath, getIdentifier(cpid), cversion,
cptype, cpmultivalued, values);
-
- return pdata;
- }
- catch (IllegalNameException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * Delete Property Values.
- *
- * @param cid
- * Property id
- * @param pdata
- * PropertyData
- * @param update
- * boolean true if it's delete-add sequence (update operation)
- * @throws IOException
- * i/O error
- * @throws SQLException
- * if database error occurs
- * @throws ValueStorageNotFoundException
- * if no such storage found with Value storageId
- */
- private void deleteValues(String cid, PropertyData pdata, boolean update) throws
IOException, SQLException,
- ValueStorageNotFoundException
- {
-
- final ResultSet valueRecords = findValuesStorageDescriptorsByPropertyId(cid);
- try
- {
- if (valueRecords.next())
- {
- // delete all Values in database
- deleteValueData(cid);
-
- do
- {
- final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC);
- if (!valueRecords.wasNull())
- {
- final ValueIOChannel channel =
valueStorageProvider.getChannel(storageId);
- try
- {
- channel.delete(pdata.getIdentifier());
- valueChanges.add(channel);
- }
- finally
- {
- channel.close();
- }
- }
- }
- while (valueRecords.next());
- }
- }
- finally
- {
- try
- {
- valueRecords.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e.getMessage());
- }
- }
- }
-
- /**
- * Read Property Values.
- *
- * @param identifier
- * property identifier
- * @param cid
- * Property id
- * @param pdata
- * PropertyData
- * @return list of ValueData
- * @throws IOException
- * i/O error
- * @throws SQLException
- * if database errro occurs
- * @throws ValueStorageNotFoundException
- * if no such storage found with Value storageId
- */
- private List<ValueData> readValues(String cid, String identifier, int cversion)
throws IOException, SQLException,
- ValueStorageNotFoundException
- {
-
- List<ValueData> data = new ArrayList<ValueData>();
-
- final ResultSet valueRecords = findValuesByPropertyId(cid);
- try
- {
- while (valueRecords.next())
- {
- final int orderNum = valueRecords.getInt(COLUMN_VORDERNUM);
- final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC);
- ValueData vdata =
- valueRecords.wasNull() ? readValueData(cid, orderNum, cversion,
valueRecords
- .getBinaryStream(COLUMN_VDATA)) : readValueData(identifier, orderNum,
storageId);
- data.add(vdata);
- }
- }
- finally
- {
- try
- {
- valueRecords.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e.getMessage());
- }
- }
-
- return data;
- }
-
- /**
- * Read ValueData from External Storage.
- *
- * @param pdata
- * PropertyData
- * @param orderNumber
- * Value order number
- * @param storageId
- * external Value storage id
- * @return ValueData
- * @throws SQLException
- * database error
- * @throws IOException
- * I/O error
- * @throws ValueStorageNotFoundException
- * if no such storage found with Value storageId
- */
- protected ValueData readValueData(String identifier, int orderNumber, String
storageId) throws SQLException,
- IOException, ValueStorageNotFoundException
- {
- ValueIOChannel channel = valueStorageProvider.getChannel(storageId);
- try
- {
- return channel.read(identifier, orderNumber, maxBufferSize);
- }
- finally
- {
- channel.close();
- }
- }
-
- /**
- * Read ValueData from database.
- *
- * @param cid
- * Property id
- * @param orderNumber
- * Value order number
- * @param version
- * persistent version (used for BLOB swapping)
- * @param content
- * @return ValueData
- * @throws SQLException
- * database error
- * @throws IOException
- * I/O error (swap)
- */
- protected ValueData readValueData(String cid, int orderNumber, int version, final
InputStream content)
- throws SQLException, IOException
- {
-
- byte[] buffer = new byte[0];
- byte[] spoolBuffer = new byte[ValueFileIOHelper.IOBUFFER_SIZE];
- int read;
- int len = 0;
- OutputStream out = null;
-
- SwapFile swapFile = null;
- try
- {
- // stream from database
- if (content != null)
- {
- while ((read = content.read(spoolBuffer)) >= 0)
- {
- if (out != null)
- {
- // spool to temp file
- out.write(spoolBuffer, 0, read);
- len += read;
- }
- else if (len + read > maxBufferSize)
- {
- // threshold for keeping data in memory exceeded;
- // create temp file and spool buffer contents
- swapFile = SwapFile.get(swapDirectory, cid + orderNumber +
"." + version);
- if (swapFile.isSpooled())
- {
- // break, value already spooled
- buffer = null;
- break;
- }
- out = PrivilegedFileHelper.fileOutputStream(swapFile);
- out.write(buffer, 0, len);
- out.write(spoolBuffer, 0, read);
- buffer = null;
- len += read;
- }
- else
- {
- // reallocate new buffer and spool old buffer contents
- byte[] newBuffer = new byte[len + read];
- System.arraycopy(buffer, 0, newBuffer, 0, len);
- System.arraycopy(spoolBuffer, 0, newBuffer, len, read);
- buffer = newBuffer;
- len += read;
- }
- }
- }
- }
- finally
- {
- if (out != null)
- {
- out.close();
- swapFile.spoolDone();
- }
- }
-
- if (buffer == null)
- {
- return new CleanableFilePersistedValueData(orderNumber, swapFile, swapCleaner);
- }
-
- return new ByteArrayPersistedValueData(orderNumber, buffer);
- }
-
- /**
- * Add Values to Property record.
- *
- * @param data
- * PropertyData
- * @throws SQLException
- * database error
- * @throws IOException
- * I/O error
- * @thorws RepositoryException if Value data large of JDBC accepted
(Integer.MAX_VALUE)
- */
- protected void addValues(String cid, PropertyData data) throws IOException,
SQLException, RepositoryException
- {
- List<ValueData> vdata = data.getValues();
-
- for (int i = 0; i < vdata.size(); i++)
- {
- ValueData vd = vdata.get(i);
- ValueIOChannel channel = valueStorageProvider.getApplicableChannel(data, i);
- InputStream stream;
- int streamLength;
- String storageId;
- if (channel == null)
- {
- // prepare write of Value in database
- if (vd.isByteArray())
- {
- byte[] dataBytes = vd.getAsByteArray();
- stream = new ByteArrayInputStream(dataBytes);
- streamLength = dataBytes.length;
- }
- else
- {
- StreamPersistedValueData streamData = (StreamPersistedValueData)vd;
-
- SwapFile swapFile = SwapFile.get(swapDirectory, cid + i + "." +
data.getPersistedVersion());
- try
- {
- writeValueHelper.writeStreamedValue(swapFile, streamData);
- }
- finally
- {
- swapFile.spoolDone();
- }
-
- long vlen = PrivilegedFileHelper.length(swapFile);
- if (vlen <= Integer.MAX_VALUE)
- {
- streamLength = (int)vlen;
- }
- else
- {
- throw new RepositoryException("Value data large of allowed by JDBC
(Integer.MAX_VALUE) " + vlen
- + ". Property " + data.getQPath().getAsString());
- }
-
- stream = streamData.getAsStream();
- }
- storageId = null;
- }
- else
- {
- // write Value in external VS
- channel.write(data.getIdentifier(), vd);
- valueChanges.add(channel);
- storageId = channel.getStorageId();
- stream = null;
- streamLength = 0;
- }
- addValueData(cid, i, stream, streamLength, storageId);
- }
- }
-
- /**
- * Build node data and its properties data from temporary stored info.
- *
- * @return NodeDataIndexing
- * @throws RepositoryException
- * @throws IOException
- * @throws SQLException
- * @throws IllegalNameException
- */
- protected NodeDataIndexing createNodeDataIndexing(TempNodeData tempNode) throws
RepositoryException, SQLException,
- IOException, IllegalNameException
- {
- String parentCid;
- QPath parentPath;
-
- if (tempNode.cpid.equals(Constants.ROOT_PARENT_UUID))
- {
- // root node
- parentCid = null;
- parentPath = Constants.ROOT_PATH;
- }
- else
- {
- parentCid = tempNode.cpid;
- parentPath =
- QPath.makeChildPath(traverseQPath(tempNode.cpid),
InternalQName.parse(tempNode.cname), tempNode.cindex);
- }
-
- // primary type if exists in the list of properties
- InternalQName ptName = null;
- ValueData ptValue = null;
-
- SortedSet<TempPropertyData> ptTempProp =
tempNode.properties.get(Constants.JCR_PRIMARYTYPE.getAsString());
- if (ptTempProp != null)
- {
- ptValue = ptTempProp.first().getValueData();
- ptName = InternalQName.parse(new String(ptValue.getAsByteArray(),
Constants.DEFAULT_ENCODING));
- }
-
- // mixins if exist in the list of properties
- List<ValueData> mixinsData = new ArrayList<ValueData>();
- List<InternalQName> mixins = new ArrayList<InternalQName>();
-
- Set<TempPropertyData> mixinsTempProps =
tempNode.properties.get(Constants.JCR_MIXINTYPES.getAsString());
- if (mixinsTempProps != null)
- {
- for (TempPropertyData mxnb : mixinsTempProps)
- {
- ValueData vdata = mxnb.getValueData();
-
- mixinsData.add(vdata);
- mixins.add(InternalQName.parse(new String(vdata.getAsByteArray(),
Constants.DEFAULT_ENCODING)));
- }
- }
-
- // build node data. No need to load ACL. The node will be pushed directly for
reindexing.
- NodeData nodeData =
- new PersistedNodeData(getIdentifier(tempNode.cid), parentPath,
getIdentifier(parentCid), tempNode.cversion,
- tempNode.cnordernumb, ptName, mixins.toArray(new
InternalQName[mixins.size()]), null);
-
- Map<String, PropertyData> childProps = new HashMap<String,
PropertyData>();
- for (String propName : tempNode.properties.keySet())
- {
- ExtendedTempPropertyData prop =
(ExtendedTempPropertyData)tempNode.properties.get(propName).first();
-
- String identifier = getIdentifier(prop.id);
- QPath qpath = QPath.makeChildPath(parentPath, InternalQName.parse(prop.name));
-
- List<ValueData> valueData = new ArrayList<ValueData>();
-
- if (propName.equals(Constants.JCR_PRIMARYTYPE.getAsString()))
- {
- valueData.add(ptValue);
- }
- else if (propName.equals(Constants.JCR_MIXINTYPES.getAsString()))
- {
- valueData = mixinsData;
- }
- else
- {
- for (TempPropertyData tempProp : tempNode.properties.get(propName))
- {
- ExtendedTempPropertyData exTempProp = (ExtendedTempPropertyData)tempProp;
-
- valueData.add(exTempProp.getValueData());
- }
- }
-
- // build property data
- PropertyData pdata =
- new PersistedPropertyData(identifier, qpath, tempNode.cid, prop.version,
prop.type, prop.multi, valueData);
-
- childProps.put(propName, pdata);
- }
-
- return new NodeDataIndexing(nodeData, childProps);
- }
-
- /**
- * Class needed temporary to store node data info.
- */
- protected class TempNodeData
- {
- public String cid;
-
- public String cname;
-
- public int cversion;
-
- public String cpid;
-
- public int cindex;
-
- public int cnordernumb;
-
- public Map<String, SortedSet<TempPropertyData>> properties = new
HashMap<String, SortedSet<TempPropertyData>>();
-
- public TempNodeData(ResultSet item) throws SQLException
- {
- cid = item.getString(COLUMN_ID);
- cname = item.getString(COLUMN_NAME);
- cversion = item.getInt(COLUMN_VERSION);
- cpid = item.getString(COLUMN_PARENTID);
- cindex = item.getInt(COLUMN_INDEX);
- cnordernumb = item.getInt(COLUMN_NORDERNUM);
- }
- }
-
- /**
- * Class needs temporary to store value info.
- */
- protected class TempPropertyData implements Comparable<TempPropertyData>
- {
- protected final int orderNum;
-
- protected ValueData data;
-
- public TempPropertyData(ResultSet item) throws SQLException
- {
- this(item, true);
- }
-
- public TempPropertyData(ResultSet item, boolean readValue) throws SQLException
- {
- orderNum = item.getInt(COLUMN_VORDERNUM);
- data = readValue ? new ByteArrayPersistedValueData(orderNum,
item.getBytes(COLUMN_VDATA)) : null;
- }
-
- public int compareTo(TempPropertyData o)
- {
- return orderNum - o.orderNum;
- }
-
- public ValueData getValueData()
- {
- return data;
- }
- }
-
- /**
- * Class needs temporary to store whole property data info.
- */
- protected class ExtendedTempPropertyData extends TempPropertyData
- {
- protected final String id;
-
- protected final String name;
-
- protected final int version;
-
- protected final int type;
-
- protected final boolean multi;
-
- protected final String storage_desc;
-
- public ExtendedTempPropertyData(ResultSet item) throws SQLException,
ValueStorageNotFoundException, IOException
- {
- super(item, false);
- id = item.getString("P_ID");
- name = item.getString("P_NAME");
- version = item.getInt("P_VERSION");
- type = item.getInt("P_TYPE");
- multi = item.getBoolean("P_MULTIVALUED");
- storage_desc = item.getString(COLUMN_VSTORAGE_DESC);
- InputStream is = item.getBinaryStream(COLUMN_VDATA);
- data =
- storage_desc == null ? readValueData(id, orderNum, version, is) :
readValueData(getIdentifier(id),
- orderNum, storage_desc);
- }
- }
-
- /**
- * The comparator used to sort the value data
- */
- protected static Comparator<ValueData> COMPARATOR_VALUE_DATA = new
Comparator<ValueData>()
- {
-
- public int compare(ValueData vd1, ValueData vd2)
- {
- return vd1.getOrderNumber() - vd2.getOrderNumber();
- }
- };
-
- protected abstract int addNodeRecord(NodeData data) throws SQLException;
-
- protected abstract int addPropertyRecord(PropertyData prop) throws SQLException;
-
- protected abstract ResultSet findItemByIdentifier(String identifier) throws
SQLException;
-
- protected abstract ResultSet findPropertyByName(String parentId, String name) throws
SQLException;
-
- protected abstract ResultSet findItemByName(String parentId, String name, int index)
throws SQLException;
-
- protected abstract ResultSet findChildNodesByParentIdentifier(String parentIdentifier)
throws SQLException;
-
- protected abstract ResultSet findLastOrderNumberByParentIdentifier(String
parentIdentifier) throws SQLException;
-
- protected abstract ResultSet findChildNodesCountByParentIdentifier(String
parentIdentifier) throws SQLException;
-
- protected abstract ResultSet findChildPropertiesByParentIdentifier(String
parentIdentifier) throws SQLException;
-
- protected abstract ResultSet findNodesAndProperties(String lastNodeId, int offset, int
limit) throws SQLException;
-
- protected abstract ResultSet findChildNodesByParentIdentifier(String parentCid, int
fromOrderNum, int toOrderNum)
- throws SQLException;
-
- protected abstract int addReference(PropertyData data) throws SQLException,
IOException;
-
- protected abstract int renameNode(NodeData data) throws SQLException;
-
- protected abstract int deleteReference(String propertyIdentifier) throws
SQLException;
-
- /**
- * Deletes [
http://www.jcp.org/jcr/1.0]lockOwner and
[
http://www.jcp.org/jcr/1.0]lockIsDeep
- * properties directly from DB.
- */
- protected abstract void deleteLockProperties() throws SQLException;
-
- /**
- * Deletes [
http://www.jcp.org/jcr/1.0]lockOwner and
[
http://www.jcp.org/jcr/1.0]lockIsDeep
- * properties directly from DB for specific parent.
- */
- protected abstract void deleteLockProperties(String nodeIdentifier) throws
SQLException;
-
- protected abstract ResultSet findReferences(String nodeIdentifier) throws
SQLException;
-
- protected abstract int deleteItemByIdentifier(String identifier) throws SQLException;
-
- protected abstract int updateNodeByIdentifier(int version, int index, int orderNumb,
String identifier)
- throws SQLException;
-
- protected abstract int updatePropertyByIdentifier(int version, int type, String
identifier) throws SQLException;
-
- protected abstract ResultSet findNodesCount() throws SQLException;
-
- // -------- values processing ------------
- protected abstract int addValueData(String cid, int orderNumber, InputStream stream,
int streamLength,
- String storageId) throws SQLException;
-
- protected abstract int deleteValueData(String cid) throws SQLException;
-
- protected abstract ResultSet findValuesByPropertyId(String cid) throws SQLException;
-
- protected abstract ResultSet findValuesStorageDescriptorsByPropertyId(String cid)
throws SQLException;
-
- protected abstract ResultSet findValueByPropertyIdOrderNumber(String cid, int
orderNumb) throws SQLException;
-
- protected abstract ResultSet findMaxPropertyVersion(String parentId, String name, int
index) throws SQLException;
-
-}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -61,7 +61,6 @@
import
org.exoplatform.services.jcr.impl.storage.jdbc.statistics.StatisticsJDBCStorageConnection;
import org.exoplatform.services.jcr.impl.storage.value.fs.FileValueStorage;
import org.exoplatform.services.jcr.impl.util.io.DirectoryHelper;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.impl.util.io.FileCleanerHolder;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerException;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;
@@ -126,11 +125,20 @@
public final static String SOURCE_NAME = "source-name";
+ @Deprecated
public final static String MULTIDB = "multi-db";
- public final static String SINGLEDB = "single-db";
+ /**
+ * Data structure type, replaces deprecated MULTI_DB
+ */
+ public final static String DB_STRUCTURE_TYPE = "db-structure-type";
/**
+ * Suffix used in tables names when isolated-databse structure used
+ */
+ public final static String DB_TABLENAME_SUFFIX = "db-tablename-suffix";
+
+ /**
* Describe which type of RDBMS will be used (DB creation metadata etc.)
*/
public final static String DB_DIALECT = "dialect";
@@ -145,49 +153,11 @@
public final static String DB_FORCE_QUERY_HINTS = "force.query.hints";
- protected final String containerName;
+ protected JDBCDataContainerConfig containerConfig;
- protected final String uniqueName;
+ public GenericConnectionFactory connFactory;
- protected final String dbSourceName;
-
- protected final boolean multiDb;
-
- protected final String dbDriver;
-
- protected final String dbDialect;
-
- protected final String dbUrl;
-
- protected final String dbUserName;
-
- protected final String dbPassword;
-
- protected final DataSourceProvider dsProvider;
-
- protected final boolean isManaged;
-
- protected final ValueStoragePluginProvider valueStorageProvider;
-
- protected String storageVersion;
-
- protected boolean checkSNSNewConnection;
-
- protected int maxBufferSize;
-
- protected File swapDirectory;
-
- protected FileCleaner swapCleaner;
-
- protected GenericConnectionFactory connFactory;
-
/**
- * Some DataBases supports query hints, that may improve query performance.
- * For default hints are enabled.
- */
- protected boolean useQueryHints;
-
- /**
* Workspace configuration.
*/
protected final WorkspaceEntry wsConfig;
@@ -209,29 +179,10 @@
/**
* SharedConnectionFactory constructor.
- *
- * @param connection
- * JDBC - connection
- * @param containerName
- * - container name
- * @param multiDb
- * - multidatabase status
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
*/
- SharedConnectionFactory(Connection connection, String containerName, boolean
multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ SharedConnectionFactory(Connection connection, JDBCDataContainerConfig
containerConfig)
{
-
- super(null, null, null, null, null, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
-
+ super(null, containerConfig);
this.connection = connection;
}
@@ -266,12 +217,19 @@
{
checkIntegrity(wsConfig, repConfig);
this.wsConfig = wsConfig;
- this.containerName = wsConfig.getName();
- this.uniqueName = wsConfig.getUniqueName();
- this.multiDb =
Boolean.parseBoolean(wsConfig.getContainer().getParameterValue(MULTIDB));
- this.valueStorageProvider = valueStorageProvider;
- this.dsProvider = dsProvider;
-
+ this.containerConfig = new JDBCDataContainerConfig();
+ this.containerConfig.containerName = wsConfig.getName();
+ this.containerConfig.uniqueName = wsConfig.getUniqueName();
+
+ this.containerConfig.dbStructureType = getDatabaseType(wsConfig);
+ String defaultSuffix = repConfig.getName() + "_" + wsConfig.getName();
+ this.containerConfig.dbTableSuffix =
+ wsConfig.getContainer().getParameterValue(DB_TABLENAME_SUFFIX,
defaultSuffix).toUpperCase();
+
+ this.containerConfig.multiDb =
!containerConfig.dbStructureType.isSingleDatabase();
+ this.containerConfig.valueStorageProvider = valueStorageProvider;
+ this.containerConfig.dsProvider = dsProvider;
+
// ------------- Database config ------------------
String pDbDialect = null;
try
@@ -314,14 +272,14 @@
if (pDbUrl != null)
{
- this.dbDriver = pDbDriver;
- this.dbUrl = pDbUrl;
- this.dbUserName = pDbUserName;
- this.dbPassword = pDbPassword;
- this.dbSourceName = null;
+ this.containerConfig.dbDriver = pDbDriver;
+ this.containerConfig.dbUrl = pDbUrl;
+ this.containerConfig.dbUserName = pDbUserName;
+ this.containerConfig.dbPassword = pDbPassword;
+ this.containerConfig.dbSourceName = null;
// A managed data source is only possible when the source name is not null
- this.isManaged = false;
- LOG.info("Connect to JCR database as user '" + this.dbUserName +
"'");
+ this.containerConfig.isManaged = false;
+ LOG.info("Connect to JCR database as user '" +
this.containerConfig.dbUserName + "'");
if (DBConstants.DB_DIALECT_GENERIC.equalsIgnoreCase(pDbDialect)
|| DBConstants.DB_DIALECT_AUTO.equalsIgnoreCase(pDbDialect))
@@ -331,10 +289,11 @@
try
{
jdbcConn =
- dbUserName != null ? DriverManager.getConnection(dbUrl, dbUserName,
dbPassword) : DriverManager
- .getConnection(dbUrl);
+ containerConfig.dbUserName != null ?
DriverManager.getConnection(containerConfig.dbUrl,
+ containerConfig.dbUserName, containerConfig.dbPassword) :
DriverManager
+ .getConnection(containerConfig.dbUrl);
- this.dbDialect = DialectDetecter.detect(jdbcConn.getMetaData());
+ this.containerConfig.dbDialect =
DialectDetecter.detect(jdbcConn.getMetaData());
}
catch (SQLException e)
{
@@ -357,15 +316,15 @@
}
else
{
- this.dbDialect = pDbDialect;
+ this.containerConfig.dbDialect = pDbDialect;
}
}
else
{
- this.dbDriver = null;
- this.dbUrl = null;
- this.dbUserName = null;
- this.dbPassword = null;
+ this.containerConfig.dbDriver = null;
+ this.containerConfig.dbUrl = null;
+ this.containerConfig.dbUserName = null;
+ this.containerConfig.dbPassword = null;
String sn;
try
@@ -377,14 +336,14 @@
// for backward comp remove in rel.2.0
sn = wsConfig.getContainer().getParameterValue("sourceName");
}
- this.dbSourceName = sn;
+ this.containerConfig.dbSourceName = sn;
if (dsProvider == null)
{
throw new IllegalArgumentException(
"Since a data source has been defined, the DataSourceProvider cannot
be null, add it in your configuration.");
}
// the data source cannot be managed if there is no transaction manager
- this.isManaged = dsProvider.isManaged(dbSourceName);
+ this.containerConfig.isManaged =
dsProvider.isManaged(containerConfig.dbSourceName);
if (pDbDialect == DBConstants.DB_DIALECT_GENERIC)
{
@@ -401,7 +360,7 @@
}
});
- this.dbDialect = DialectDetecter.detect(jdbcConn.getMetaData());
+ this.containerConfig.dbDialect =
DialectDetecter.detect(jdbcConn.getMetaData());
}
catch (SQLException e)
{
@@ -424,50 +383,54 @@
}
else
{
- this.dbDialect = pDbDialect;
+ this.containerConfig.dbDialect = pDbDialect;
}
}
- LOG.info("Using a dialect '" + this.dbDialect + "'");
+ LOG.info("Using a dialect '" + this.containerConfig.dbDialect +
"'");
// check is there DB_FORCE_QUERY_HINTS parameter - by default its enabled
- useQueryHints = wsConfig.getContainer().getParameterBoolean(DB_FORCE_QUERY_HINTS,
true);
+ containerConfig.useQueryHints =
wsConfig.getContainer().getParameterBoolean(DB_FORCE_QUERY_HINTS, true);
try
{
- this.checkSNSNewConnection =
wsConfig.getContainer().getParameterBoolean(CHECK_SNS_NEW_CONNECTION);
+ this.containerConfig.checkSNSNewConnection =
+ wsConfig.getContainer().getParameterBoolean(CHECK_SNS_NEW_CONNECTION);
}
catch (RepositoryConfigurationException e)
{
// don't use new connection by default
- this.checkSNSNewConnection = false;
+ this.containerConfig.checkSNSNewConnection = false;
}
// ------------- Values swap config ------------------
try
{
- this.maxBufferSize =
wsConfig.getContainer().getParameterInteger(MAXBUFFERSIZE_PROP);
+ this.containerConfig.maxBufferSize =
wsConfig.getContainer().getParameterInteger(MAXBUFFERSIZE_PROP);
}
catch (RepositoryConfigurationException e)
{
- this.maxBufferSize = DEF_MAXBUFFERSIZE;
+ this.containerConfig.maxBufferSize = DEF_MAXBUFFERSIZE;
}
try
{
String sdParam = wsConfig.getContainer().getParameterValue(SWAPDIR_PROP);
- this.swapDirectory = new File(sdParam);
+ this.containerConfig.swapDirectory = new File(sdParam);
}
catch (RepositoryConfigurationException e1)
{
- this.swapDirectory = new File(DEF_SWAPDIR);
+ this.containerConfig.swapDirectory = new File(DEF_SWAPDIR);
}
- if (!PrivilegedFileHelper.exists(swapDirectory))
+ if (!PrivilegedFileHelper.exists(containerConfig.swapDirectory))
{
- PrivilegedFileHelper.mkdirs(swapDirectory);
+ PrivilegedFileHelper.mkdirs(containerConfig.swapDirectory);
}
- this.swapCleaner = fileCleanerHolder.getFileCleaner();
+ this.containerConfig.swapCleaner = fileCleanerHolder.getFileCleaner();
+ this.containerConfig.initScriptPath =
+ DBInitializerHelper.scriptPath(containerConfig.dbDialect,
containerConfig.dbStructureType.isSimpleTable());
+
initDatabase();
LOG.info(getInfo());
@@ -485,14 +448,12 @@
protected GenericConnectionFactory defaultConnectionFactory() throws NamingException,
RepositoryException
{
// by default
- if (dbSourceName != null)
+ if (containerConfig.dbSourceName != null)
{
- return new GenericConnectionFactory(getDataSource(), containerName, multiDb,
valueStorageProvider,
- maxBufferSize, swapDirectory, swapCleaner);
+ return new GenericConnectionFactory(getDataSource(), containerConfig);
}
- return new GenericConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new GenericConnectionFactory(containerConfig);
}
/**
@@ -508,10 +469,9 @@
* @throws IOException
* on I/O error
*/
- protected StorageDBInitializer defaultDBInitializer(String sqlPath) throws
NamingException, RepositoryException,
- IOException
+ protected StorageDBInitializer defaultDBInitializer() throws NamingException,
RepositoryException, IOException
{
- return new StorageDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
+ return new StorageDBInitializer(this.connFactory.getJdbcConnection(),
containerConfig);
}
/**
@@ -527,7 +487,7 @@
protected void checkIntegrity(WorkspaceEntry wsConfig, RepositoryEntry repConfig)
throws RepositoryConfigurationException
{
- boolean isMulti;
+ JDBCDataContainerConfig.DatabaseStructureType dbType;
for (WorkspaceEntry wsEntry : repConfig.getWorkspaceEntries())
{
if (wsEntry.getName().equals(wsConfig.getName())
@@ -537,16 +497,14 @@
continue;
}
- // MULTIDB
- if (!wsEntry.getContainer().getParameterValue(MULTIDB)
- .equals(wsConfig.getContainer().getParameterValue(MULTIDB)))
+ if (!getDatabaseType(wsEntry).equals(getDatabaseType(wsConfig)))
{
- throw new RepositoryConfigurationException("All workspaces must be
" + MULTIDB + " or " + SINGLEDB
- + ". But " + wsEntry.getName() + "- multi-db=" +
wsEntry.getContainer().getParameterValue(MULTIDB)
- + " and " + wsConfig.getName() + "- multi-db=" +
wsConfig.getContainer().getParameterValue(MULTIDB));
+ throw new RepositoryConfigurationException("All workspaces must be of
same DB type. But "
+ + wsEntry.getName() + "- multi-db=" + getDatabaseType(wsEntry) +
" and " + wsConfig.getName()
+ + "- multi-db=" + getDatabaseType(wsConfig));
}
- isMulti =
Boolean.parseBoolean(wsConfig.getContainer().getParameterValue(MULTIDB));
+ dbType = getDatabaseType(wsConfig);
// source name
String wsSourceName = null;
@@ -566,21 +524,21 @@
if (wsSourceName != null && newWsSourceName != null)
{
- if (isMulti)
+ if (dbType.isSingleDatabase())
{
- if (wsSourceName.equals(newWsSourceName))
+ if (!wsSourceName.equals(newWsSourceName))
{
- throw new RepositoryConfigurationException("SourceName " +
wsSourceName + " alredy in use in "
- + wsEntry.getName() + ". SourceName must be different in "
+ MULTIDB
- + ". Check configuration for " + wsConfig.getName());
+ throw new RepositoryConfigurationException("SourceName must be
equals in " + dbType
+ + "-database repository." + " Check " +
wsEntry.getName() + " and " + wsConfig.getName());
}
}
else
{
- if (!wsSourceName.equals(newWsSourceName))
+ if (wsSourceName.equals(newWsSourceName))
{
- throw new RepositoryConfigurationException("SourceName must be
equals in " + SINGLEDB + " "
- + "repository." + " Check " + wsEntry.getName()
+ " and " + wsConfig.getName());
+ throw new RepositoryConfigurationException("SourceName " +
wsSourceName + " alredy in use in "
+ + wsEntry.getName() + ". SourceName must be different in "
+ dbType
+ + "-database structure type. Check configuration for " +
wsConfig.getName());
}
}
continue;
@@ -604,22 +562,21 @@
if (wsUri != null && newWsUri != null)
{
- if (isMulti)
+ if (dbType.isSingleDatabase())
{
- if (wsUri.equals(newWsUri))
+ if (!wsUri.equals(newWsUri))
{
- throw new RepositoryConfigurationException("db-url " + wsUri
+ " alredy in use in "
- + wsEntry.getName() + ". db-url must be different in " +
MULTIDB + ". Check configuration for "
- + wsConfig.getName());
-
+ throw new RepositoryConfigurationException("db-url must be equals
in " + dbType
+ + "-database repository." + " Check " +
wsEntry.getName() + " and " + wsConfig.getName());
}
}
else
{
- if (!wsUri.equals(newWsUri))
+ if (wsUri.equals(newWsUri))
{
- throw new RepositoryConfigurationException("db-url must be equals
in " + SINGLEDB + " "
- + "repository." + " Check " + wsEntry.getName()
+ " and " + wsConfig.getName());
+ throw new RepositoryConfigurationException("db-url " + wsUri
+ " alredy in use in "
+ + wsEntry.getName() + ". db-url must be different in " +
dbType
+ + "-database structure type. Check configuration for " +
wsConfig.getName());
}
}
}
@@ -640,111 +597,102 @@
{
StorageDBInitializer dbInitializer = null;
- String sqlPath = DBInitializerHelper.scriptPath(dbDialect, multiDb);
- if (dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
+ if (containerConfig.dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
{
LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is
experimental!");
// sample of connection factory customization
- if (dbSourceName != null)
+ if (containerConfig.dbSourceName != null)
{
this.connFactory = defaultConnectionFactory();
}
else
{
- this.connFactory =
- new OracleConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ this.connFactory = new OracleConnectionFactory(containerConfig);
}
// a particular db initializer may be configured here too
- dbInitializer = new OracleDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
+ dbInitializer = new OracleDBInitializer(this.connFactory.getJdbcConnection(),
containerConfig);
}
- else if (dbDialect == DBConstants.DB_DIALECT_ORACLE)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_ORACLE)
{
this.connFactory = defaultConnectionFactory();
- dbInitializer = new OracleDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
+ dbInitializer = new OracleDBInitializer(this.connFactory.getJdbcConnection(),
containerConfig);
}
- else if (dbDialect == DBConstants.DB_DIALECT_PGSQL)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_PGSQL)
{
this.connFactory = defaultConnectionFactory();
- dbInitializer = new PgSQLDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
+ dbInitializer = new PgSQLDBInitializer(this.connFactory.getJdbcConnection(),
containerConfig);
}
- else if (dbDialect == DBConstants.DB_DIALECT_MYSQL || dbDialect ==
DBConstants.DB_DIALECT_MYSQL_UTF8
- || dbDialect == DBConstants.DB_DIALECT_MYSQL_MYISAM || dbDialect ==
DBConstants.DB_DIALECT_MYSQL_MYISAM_UTF8)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_MYSQL
+ || containerConfig.dbDialect == DBConstants.DB_DIALECT_MYSQL_UTF8
+ || containerConfig.dbDialect == DBConstants.DB_DIALECT_MYSQL_MYISAM
+ || containerConfig.dbDialect == DBConstants.DB_DIALECT_MYSQL_MYISAM_UTF8)
{
- if (dbDialect == DBConstants.DB_DIALECT_MYSQL_MYISAM || dbDialect ==
DBConstants.DB_DIALECT_MYSQL_MYISAM_UTF8)
+ if (containerConfig.dbDialect == DBConstants.DB_DIALECT_MYSQL_MYISAM
+ || containerConfig.dbDialect == DBConstants.DB_DIALECT_MYSQL_MYISAM_UTF8)
{
LOG.warn("MyISAM is not supported due to its lack of transaction support
and integrity check, so use it only"
+ " if you don't expect any support and performances in read
accesses are more important than the consistency"
+ " in your use-case. This dialect is only dedicated to the
community.");
}
- if (dbSourceName != null)
+ if (containerConfig.dbSourceName != null)
{
- this.connFactory =
- new MySQLConnectionFactory(getDataSource(), containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ this.connFactory = new MySQLConnectionFactory(getDataSource(),
containerConfig);
}
else
{
- this.connFactory =
- new MySQLConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ this.connFactory = new MySQLConnectionFactory(containerConfig);
}
- dbInitializer = defaultDBInitializer(sqlPath);
+ dbInitializer = defaultDBInitializer();
}
- else if (dbDialect == DBConstants.DB_DIALECT_MSSQL)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_MSSQL)
{
this.connFactory = defaultConnectionFactory();
- dbInitializer = defaultDBInitializer(sqlPath);
+ dbInitializer = defaultDBInitializer();
}
- else if (dbDialect == DBConstants.DB_DIALECT_DERBY)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_DERBY)
{
this.connFactory = defaultConnectionFactory();
- dbInitializer = defaultDBInitializer(sqlPath);
+ dbInitializer = defaultDBInitializer();
}
- else if (dbDialect == DBConstants.DB_DIALECT_DB2)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_DB2)
{
this.connFactory = defaultConnectionFactory();
- dbInitializer = defaultDBInitializer(sqlPath);
+ dbInitializer = defaultDBInitializer();
}
- else if (dbDialect == DBConstants.DB_DIALECT_DB2V8)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_DB2V8)
{
this.connFactory = defaultConnectionFactory();
- dbInitializer = defaultDBInitializer(sqlPath);
+ dbInitializer = defaultDBInitializer();
}
- else if (dbDialect == DBConstants.DB_DIALECT_SYBASE)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_SYBASE)
{
this.connFactory = defaultConnectionFactory();
- dbInitializer = defaultDBInitializer(sqlPath);
+ dbInitializer = defaultDBInitializer();
}
- else if (dbDialect == DBConstants.DB_DIALECT_INGRES)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_INGRES)
{
this.connFactory = defaultConnectionFactory();
// using Postgres initializer
- dbInitializer =
- new IngresSQLDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
+ dbInitializer = new IngresSQLDBInitializer(this.connFactory.getJdbcConnection(),
containerConfig);
}
- else if (dbDialect == DBConstants.DB_DIALECT_HSQLDB)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_HSQLDB)
{
- if (dbSourceName != null)
+ if (containerConfig.dbSourceName != null)
{
- this.connFactory =
- new HSQLDBConnectionFactory(getDataSource(), containerName, multiDb,
valueStorageProvider,
- maxBufferSize, swapDirectory, swapCleaner);
+ this.connFactory = new HSQLDBConnectionFactory(getDataSource(),
containerConfig);
}
else
{
- this.connFactory =
- new HSQLDBConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ this.connFactory = new HSQLDBConnectionFactory(containerConfig);
}
- dbInitializer = defaultDBInitializer(sqlPath);
+ dbInitializer = defaultDBInitializer();
}
else
{
// generic, DB_HSQLDB
this.connFactory = defaultConnectionFactory();
- dbInitializer = defaultDBInitializer(sqlPath);
+ dbInitializer = defaultDBInitializer();
}
// database type
@@ -807,8 +755,7 @@
if (original instanceof JDBCStorageConnection)
{
WorkspaceStorageConnectionFactory cFactory =
- new
SharedConnectionFactory(((JDBCStorageConnection)original).getJdbcConnection(),
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ new
SharedConnectionFactory(((JDBCStorageConnection)original).getJdbcConnection(),
containerConfig);
return STATISTICS_ENABLED ? new
StatisticsJDBCStorageConnection(cFactory.openConnection(false)) : cFactory
.openConnection(false);
@@ -824,7 +771,7 @@
*/
public String getName()
{
- return containerName;
+ return containerConfig.containerName;
}
/**
@@ -832,7 +779,7 @@
*/
public String getUniqueName()
{
- return uniqueName;
+ return containerConfig.uniqueName;
}
/**
@@ -841,11 +788,12 @@
public String getInfo()
{
String str =
- "JDBC based JCR Workspace Data container \n" + "container name:
" + containerName + " \n"
- + (isManaged ? "managed " : "") + "data source JNDI
name: " + dbSourceName + "\n" + "is multi database: "
- + multiDb + "\n" + "storage version: " + storageVersion +
"\n" + "value storage provider: "
- + valueStorageProvider + "\n" + "max buffer size (bytes):
" + maxBufferSize + "\n"
- + "swap directory path: " +
PrivilegedFileHelper.getAbsolutePath(swapDirectory);
+ "JDBC based JCR Workspace Data container \n" + "container name:
" + containerConfig.containerName + " \n"
+ + (containerConfig.isManaged ? "managed " : "") +
"data source JNDI name: " + containerConfig.dbSourceName
+ + "\n" + "is multi database: " + containerConfig.multiDb
+ "\n" + "storage version: "
+ + containerConfig.storageVersion + "\n" + "value storage
provider: " + containerConfig.valueStorageProvider
+ + "\n" + "max buffer size (bytes): " +
containerConfig.maxBufferSize + "\n" + "swap directory path: "
+ + PrivilegedFileHelper.getAbsolutePath(containerConfig.swapDirectory);
return str;
}
@@ -854,7 +802,7 @@
*/
public String getStorageVersion()
{
- return storageVersion;
+ return containerConfig.storageVersion;
}
/**
@@ -898,7 +846,7 @@
}
}
}
-
+
// Remove lock properties from DB. It is an issue of migration locks from 1.12.x to
1.14.x in case when we use
// shareable cache. The lock tables will be new but still remaining lock properties
in JCR tables.
boolean deleteLocks =
@@ -983,7 +931,7 @@
*/
protected String getDbSourceName()
{
- return dbSourceName;
+ return containerConfig.dbSourceName;
}
/**
@@ -993,7 +941,7 @@
*/
protected String getDbDriver()
{
- return dbDriver;
+ return containerConfig.dbDriver;
}
/**
@@ -1003,7 +951,7 @@
*/
protected String getDbUrl()
{
- return dbUrl;
+ return containerConfig.dbUrl;
}
/**
@@ -1013,7 +961,7 @@
*/
protected String getDbUserName()
{
- return dbUserName;
+ return containerConfig.dbUserName;
}
/**
@@ -1021,7 +969,7 @@
*/
public boolean isCheckSNSNewConnection()
{
- return checkSNSNewConnection;
+ return containerConfig.checkSNSNewConnection;
}
/**
@@ -1076,12 +1024,12 @@
new ObjectWriterImpl(PrivilegedFileHelper.fileOutputStream(new
File(storageDir,
"JDBCWorkspaceDataContainer.info")));
- backupInfo.writeString(containerName);
- backupInfo.writeBoolean(multiDb);
+ backupInfo.writeString(containerConfig.containerName);
+ backupInfo.writeBoolean(containerConfig.multiDb);
Map<String, String> scripts = new HashMap<String, String>();
- if (multiDb)
+ if (containerConfig.multiDb)
{
scripts.put("JCR_MITEM", "select * from JCR_MITEM where
JCR_MITEM.NAME <> '" + Constants.ROOT_PARENT_NAME
+ "'");
@@ -1090,13 +1038,14 @@
}
else
{
- scripts.put("JCR_SITEM", "select * from JCR_SITEM where
CONTAINER_NAME='" + containerName + "'");
+ scripts.put("JCR_SITEM", "select * from JCR_SITEM where
CONTAINER_NAME='" + containerConfig.containerName
+ + "'");
scripts.put("JCR_SVALUE",
"select V.* from JCR_SVALUE V, JCR_SITEM I where I.ID=V.PROPERTY_ID
and I.CONTAINER_NAME='"
- + containerName + "'");
+ + containerConfig.containerName + "'");
scripts.put("JCR_SREF",
"select R.* from JCR_SREF R, JCR_SITEM I where I.ID=R.PROPERTY_ID and
I.CONTAINER_NAME='"
- + containerName + "'");
+ + containerConfig.containerName + "'");
}
// using existing DataSource to get a JDBC Connection.
@@ -1205,17 +1154,17 @@
Map<String, RestoreTableRule> tables = new LinkedHashMap<String,
RestoreTableRule>();
// ITEM table
- String dstTableName = "JCR_" + (multiDb ? "M" :
"S") + "ITEM";
+ String dstTableName = "JCR_" + (containerConfig.multiDb ?
"M" : "S") + "ITEM";
String srcTableName = "JCR_" + (srcMultiDb ? "M" :
"S") + "ITEM";
RestoreTableRule restoreTableRule = new RestoreTableRule();
restoreTableRule.setSrcContainerName(srcContainerName);
restoreTableRule.setSrcMultiDb(srcMultiDb);
- restoreTableRule.setDstContainerName(containerName);
- restoreTableRule.setDstMultiDb(multiDb);
+ restoreTableRule.setDstContainerName(containerConfig.containerName);
+ restoreTableRule.setDstMultiDb(containerConfig.multiDb);
restoreTableRule.setSrcTableName(srcTableName);
- if (multiDb)
+ if (containerConfig.multiDb)
{
if (!srcMultiDb)
{
@@ -1257,20 +1206,20 @@
tables.put(dstTableName, restoreTableRule);
// VALUE table
- dstTableName = "JCR_" + (multiDb ? "M" : "S") +
"VALUE";
+ dstTableName = "JCR_" + (containerConfig.multiDb ? "M" :
"S") + "VALUE";
srcTableName = "JCR_" + (srcMultiDb ? "M" : "S") +
"VALUE";
restoreTableRule = new RestoreTableRule();
restoreTableRule.setSrcContainerName(srcContainerName);
restoreTableRule.setSrcMultiDb(srcMultiDb);
- restoreTableRule.setDstContainerName(containerName);
- restoreTableRule.setDstMultiDb(multiDb);
+ restoreTableRule.setDstContainerName(containerConfig.containerName);
+ restoreTableRule.setDstMultiDb(containerConfig.multiDb);
restoreTableRule.setSrcTableName(srcTableName);
// auto increment ID column
restoreTableRule.setSkipColumnIndex(0);
- if (!multiDb || !srcMultiDb)
+ if (!containerConfig.multiDb || !srcMultiDb)
{
// PROPERTY_ID column index
Set<Integer> convertColumnIndex = new HashSet<Integer>();
@@ -1280,17 +1229,17 @@
tables.put(dstTableName, restoreTableRule);
// REF tables
- dstTableName = "JCR_" + (multiDb ? "M" : "S") +
"REF";
+ dstTableName = "JCR_" + (containerConfig.multiDb ? "M" :
"S") + "REF";
srcTableName = "JCR_" + (srcMultiDb ? "M" : "S") +
"REF";
restoreTableRule = new RestoreTableRule();
restoreTableRule.setSrcContainerName(srcContainerName);
restoreTableRule.setSrcMultiDb(srcMultiDb);
- restoreTableRule.setDstContainerName(containerName);
- restoreTableRule.setDstMultiDb(multiDb);
+ restoreTableRule.setDstContainerName(containerConfig.containerName);
+ restoreTableRule.setDstMultiDb(containerConfig.multiDb);
restoreTableRule.setSrcTableName(srcTableName);
- if (!multiDb || !srcMultiDb)
+ if (!containerConfig.multiDb || !srcMultiDb)
{
// NODE_ID and PROPERTY_ID column indexes
Set<Integer> convertColumnIndex = new HashSet<Integer>();
@@ -1317,7 +1266,7 @@
}
}
- restorers.add(new DBRestore(storageDir, jdbcConn, tables, wsConfig, swapCleaner,
dbCleaner));
+ restorers.add(new DBRestore(storageDir, jdbcConn, tables, wsConfig,
containerConfig.swapCleaner, dbCleaner));
// prepare value storage restorer
if (wsConfig.getContainer().getValueStorages() != null)
@@ -1439,11 +1388,12 @@
{
try
{
- return dsProvider.getDataSource(dbSourceName);
+ return containerConfig.dsProvider.getDataSource(containerConfig.dbSourceName);
}
catch (NamingException e)
{
- throw new RepositoryException("Datasource '" + dbSourceName +
"' is not bound in this context.", e);
+ throw new RepositoryException("Datasource '" +
containerConfig.dbSourceName
+ + "' is not bound in this context.", e);
}
}
@@ -1469,4 +1419,30 @@
return DBConstants.DB_DIALECT_GENERIC; // by default
}
+ /**
+ * @param wsConfig
+ * @return
+ * @throws RepositoryConfigurationException
+ */
+ public static JDBCDataContainerConfig.DatabaseStructureType
getDatabaseType(WorkspaceEntry wsConfig)
+ throws RepositoryConfigurationException
+ {
+ try
+ {
+ if (wsConfig.getContainer().getParameterBoolean(MULTIDB))
+ {
+ return JDBCDataContainerConfig.DatabaseStructureType.MULTI;
+ }
+ else
+ {
+ return JDBCDataContainerConfig.DatabaseStructureType.SINGLE;
+ }
+ }
+ catch (Exception e)
+ {
+ // parameter MULTIDB is missing
+ String dbStructureType =
wsConfig.getContainer().getParameterValue(DB_STRUCTURE_TYPE).toUpperCase();
+ return JDBCDataContainerConfig.DatabaseStructureType.valueOf(dbStructureType);
+ }
+ }
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -157,16 +157,15 @@
}
}
- private void checkConsistencyInJCRITEM(Set<String> lockedInJCRITEM,
Set<String> lockedInJCRLOCK,
- boolean autoRepair) throws RepositoryException, SQLException
+ private void checkConsistencyInJCRITEM(Set<String> lockedInJCRITEM,
Set<String> lockedInJCRLOCK, boolean autoRepair)
+ throws RepositoryException, SQLException
{
for (String nodeId : lockedInJCRITEM)
{
if (!lockedInJCRLOCK.contains(nodeId))
{
- logBrokenObjectAndSetInconsistency("Lock exists in ITEM table but not in
LOCK table. Node UUID: "
- + nodeId);
-
+ logBrokenObjectAndSetInconsistency("Lock exists in ITEM table but not in
LOCK table. Node UUID: " + nodeId);
+
if (autoRepair)
{
WorkspaceStorageConnection conn = jdbcDataContainer.openConnection();
@@ -224,7 +223,7 @@
public void checkDataBase(boolean autoRepair)
{
SecurityHelper.validateSecurityPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
-
+
Connection jdbcConn = null;
try
{
@@ -396,7 +395,8 @@
private String removeWorkspacePrefix(String str)
{
- return jdbcDataContainer.multiDb ? str :
str.substring(jdbcDataContainer.containerName.length());
+ return jdbcDataContainer.containerConfig.multiDb ? str : str
+ .substring(jdbcDataContainer.containerConfig.containerName.length());
}
private String getBrokenObject(ResultSet resultSet, String[] fieldNames)
@@ -417,7 +417,7 @@
}
record.append(' ');
}
-
+
return record.toString();
}
@@ -472,107 +472,112 @@
private void initInspectionQueries()
{
vsInspectionQuery =
- new InspectionQuery(jdbcDataContainer.multiDb
+ new InspectionQuery(jdbcDataContainer.containerConfig.multiDb
? "select PROPERTY_ID, ORDER_NUM, STORAGE_DESC from JCR_MVALUE where
STORAGE_DESC is not null"
: "select V.PROPERTY_ID, V.ORDER_NUM, V.STORAGE_DESC from JCR_SVALUE V,
JCR_SITEM I"
- + " where I.CONTAINER_NAME='" +
jdbcDataContainer.containerName
- + "' and V.PROPERTY_ID = I.ID and STORAGE_DESC is not
null",
- new String[]{DBConstants.COLUMN_VPROPERTY_ID, DBConstants.COLUMN_VORDERNUM,
- DBConstants.COLUMN_VSTORAGE_DESC}, "Items with value data stored in
value storage", new DummyRepair());
+ + " where I.CONTAINER_NAME='" +
jdbcDataContainer.containerConfig.containerName
+ + "' and V.PROPERTY_ID = I.ID and STORAGE_DESC is not null",
new String[]{
+ DBConstants.COLUMN_VPROPERTY_ID, DBConstants.COLUMN_VORDERNUM,
DBConstants.COLUMN_VSTORAGE_DESC},
+ "Items with value data stored in value storage", new
DummyRepair());
lockInspectionQuery =
- new InspectionQuery(jdbcDataContainer.multiDb ? "select distinct PARENT_ID
from JCR_MITEM where I_CLASS=2 AND"
- + " (
NAME='[http://www.jcp.org/jcr/1.0]lockOwner' OR
NAME='[http://www.jcp.org/jcr/1.0]lockIsDeep')"
- : "select distinct PARENT_ID from JCR_SITEM WHERE
CONTAINER_NAME='" + jdbcDataContainer.containerName + "'"
+ new InspectionQuery(jdbcDataContainer.containerConfig.multiDb
+ ? "select distinct PARENT_ID from JCR_MITEM where I_CLASS=2 AND"
+ + " (
NAME='[http://www.jcp.org/jcr/1.0]lockOwner' OR
NAME='[http://www.jcp.org/jcr/1.0]lockIsDeep')"
+ : "select distinct PARENT_ID from JCR_SITEM WHERE
CONTAINER_NAME='"
+ + jdbcDataContainer.containerConfig.containerName + "'"
+ " AND I_CLASS=2 and
(
NAME='[http://www.jcp.org/jcr/1.0]lockOwner'"
+ " OR
NAME='[http://www.jcp.org/jcr/1.0]lockIsDeep')",
new String[]{DBConstants.COLUMN_PARENTID},
"Items which have jcr:lockOwner and jcr:lockIsDeep properties", new
DummyRepair());
// ITEM tables
- itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
+ itemsInspectionQuery.add(new
InspectionQuery(jdbcDataContainer.containerConfig.multiDb
? "select * from JCR_MITEM I where NOT EXISTS(select * from JCR_MITEM P
where P.ID = I.PARENT_ID)"
- : "select * from JCR_SITEM I where I.CONTAINER_NAME='" +
jdbcDataContainer.containerName
+ : "select * from JCR_SITEM I where I.CONTAINER_NAME='" +
jdbcDataContainer.containerConfig.containerName
+ "' and NOT EXISTS(select * from JCR_SITEM P where P.ID =
I.PARENT_ID)", new String[]{
DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME,
DBConstants.COLUMN_CLASS},
- "Items that do not have parent nodes", new
RootAsParentAssigner(jdbcDataContainer
- .getConnectionFactory())));
+ "Items that do not have parent nodes", new
RootAsParentAssigner(jdbcDataContainer.getConnectionFactory())));
itemsInspectionQuery
.add(new InspectionQueryFilteredMultivaluedProperties(
- jdbcDataContainer.multiDb
+ jdbcDataContainer.containerConfig.multiDb
? "select * from JCR_MITEM P where P.I_CLASS=2 and P.P_MULTIVALUED=?
and NOT EXISTS( select * from JCR_MVALUE V "
+ "where V.PROPERTY_ID=P.ID)" : "select * from JCR_SITEM
P where P.CONTAINER_NAME='"
- + jdbcDataContainer.containerName + "' and P.I_CLASS=2"
+ + jdbcDataContainer.containerConfig.containerName + "' and
P.I_CLASS=2"
+ " and P.P_MULTIVALUED=? and NOT EXISTS( select * from JCR_SVALUE
V where V.PROPERTY_ID=P.ID)",
new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID,
DBConstants.COLUMN_NAME},
"A node that has a single valued properties with nothing declared in the
VALUE table.",
new PropertyRemover(jdbcDataContainer.getConnectionFactory(),
nodeTypeManager)));
- itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
+ itemsInspectionQuery.add(new
InspectionQuery(jdbcDataContainer.containerConfig.multiDb
? "select * from JCR_MITEM N where N.I_CLASS=1 and NOT EXISTS "
+ "(select * from JCR_MITEM P where P.I_CLASS=2 and P.PARENT_ID=N.ID
"
+ "and
P.NAME='[http://www.jcp.org/jcr/1.0]primaryType')"
- : "select * from JCR_SITEM N where N.CONTAINER_NAME='" +
jdbcDataContainer.containerName
+ : "select * from JCR_SITEM N where N.CONTAINER_NAME='" +
jdbcDataContainer.containerConfig.containerName
+ "' and N.I_CLASS=1 and NOT EXISTS (select * from JCR_SITEM P
"
+ "where P.I_CLASS=2 and P.PARENT_ID=N.ID and
P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' "
- + "and P.CONTAINER_NAME='" + jdbcDataContainer.containerName +
"')", new String[]{DBConstants.COLUMN_ID,
- DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME}, "A node that
doesn't have primary type property",
- new NodeRemover(jdbcDataContainer.getConnectionFactory(), nodeTypeManager)));
+ + "and P.CONTAINER_NAME='" +
jdbcDataContainer.containerConfig.containerName + "')", new String[]{
+ DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
+ "A node that doesn't have primary type property", new
NodeRemover(jdbcDataContainer.getConnectionFactory(),
+ nodeTypeManager)));
- itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
+ itemsInspectionQuery.add(new
InspectionQuery(jdbcDataContainer.containerConfig.multiDb
? "select * from JCR_MVALUE V where NOT EXISTS(select * from JCR_MITEM P
"
+ "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)"
: "select * from JCR_SVALUE V where NOT EXISTS(select * from JCR_SITEM P
"
+ "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)", new
String[]{DBConstants.COLUMN_ID,
DBConstants.COLUMN_VPROPERTY_ID}, "All value records that has not related
property record",
- new ValueRecordsRemover(jdbcDataContainer.getConnectionFactory(),
jdbcDataContainer.containerName,
- jdbcDataContainer.multiDb)));
+ new ValueRecordsRemover(jdbcDataContainer.getConnectionFactory(),
+ jdbcDataContainer.containerConfig.containerName,
jdbcDataContainer.containerConfig.multiDb)));
// The differences in the queries by DB dialect.
String statement;
- if (jdbcDataContainer.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE))
+ if
(jdbcDataContainer.containerConfig.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE))
{
statement =
- jdbcDataContainer.multiDb
+ jdbcDataContainer.containerConfig.multiDb
? "select * from JCR_MVALUE where (STORAGE_DESC is not null and not
DATA like null)"
: "select V.* from JCR_SVALUE V, JCR_SITEM I where V.PROPERTY_ID =
I.ID and I.CONTAINER_NAME='"
- + jdbcDataContainer.containerName + "' AND ((STORAGE_DESC is
not null and not DATA like null))";
+ + jdbcDataContainer.containerConfig.containerName
+ + "' AND ((STORAGE_DESC is not null and not DATA like
null))";
}
- else if
(jdbcDataContainer.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLE)
- ||
jdbcDataContainer.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLEOCI))
+ else if
(jdbcDataContainer.containerConfig.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLE)
+ ||
jdbcDataContainer.containerConfig.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLEOCI))
{
statement =
- jdbcDataContainer.multiDb
+ jdbcDataContainer.containerConfig.multiDb
? "select * from JCR_MVALUE where (STORAGE_DESC is not null and DATA
is not null)"
: "select V.* from JCR_SVALUE V, JCR_SITEM I where V.PROPERTY_ID =
I.ID and I.CONTAINER_NAME='"
- + jdbcDataContainer.containerName + "' AND (STORAGE_DESC is
not null and DATA is not null)";
+ + jdbcDataContainer.containerConfig.containerName
+ + "' AND (STORAGE_DESC is not null and DATA is not
null)";
}
else
{
statement =
- jdbcDataContainer.multiDb
+ jdbcDataContainer.containerConfig.multiDb
? "select * from JCR_MVALUE where (STORAGE_DESC is not null and DATA
is not null)"
: "select V.* from JCR_SVALUE V, JCR_SITEM I where V.PROPERTY_ID =
I.ID and I.CONTAINER_NAME='"
- + jdbcDataContainer.containerName + "' AND ((STORAGE_DESC is
not null and DATA is not null))";
+ + jdbcDataContainer.containerConfig.containerName
+ + "' AND ((STORAGE_DESC is not null and DATA is not
null))";
}
itemsInspectionQuery.add(new InspectionQuery(statement, new
String[]{DBConstants.COLUMN_ID},
"Incorrect VALUE records. Both fields STORAGE_DESC and DATA contain not
null value.", new DummyRepair()));
- itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
+ itemsInspectionQuery.add(new
InspectionQuery(jdbcDataContainer.containerConfig.multiDb
? "select * from JCR_MITEM I where I.ID = I.PARENT_ID and I.NAME <>
'" + Constants.ROOT_PARENT_NAME + "'"
: "select * from JCR_SITEM I where I.ID = I.PARENT_ID and
I.CONTAINER_NAME='"
- + jdbcDataContainer.containerName + "' and I.NAME <>
'" + Constants.ROOT_PARENT_NAME + "'", new String[]{
- DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
"An item is its own parent.",
- new RootAsParentAssigner(jdbcDataContainer.getConnectionFactory())));
+ + jdbcDataContainer.containerConfig.containerName + "' and I.NAME
<> '" + Constants.ROOT_PARENT_NAME + "'",
+ new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID,
DBConstants.COLUMN_NAME},
+ "An item is its own parent.", new
RootAsParentAssigner(jdbcDataContainer.getConnectionFactory())));
itemsInspectionQuery
.add(new InspectionQuery(
- jdbcDataContainer.multiDb
+ jdbcDataContainer.containerConfig.multiDb
? "select * from JCR_MITEM I where EXISTS (select * from JCR_MITEM
J"
+ " WHERE I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and
I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
+ " and I.VERSION != J.VERSION)"
: "select * from JCR_SITEM I where I.CONTAINER_NAME='"
- + jdbcDataContainer.containerName
+ + jdbcDataContainer.containerConfig.containerName
+ "' and EXISTS (select * from JCR_SITEM J WHERE
I.CONTAINER_NAME = J.CONTAINER_NAME and"
+ " I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX =
J.I_INDEX and I.I_CLASS = J.I_CLASS"
+ " and I.VERSION != J.VERSION)",
@@ -580,14 +585,14 @@
DBConstants.COLUMN_VERSION, DBConstants.COLUMN_CLASS,
DBConstants.COLUMN_INDEX},
"Several versions of same item.", new
EarlierVersionsRemover(jdbcDataContainer.getConnectionFactory())));
- itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
+ itemsInspectionQuery.add(new
InspectionQuery(jdbcDataContainer.containerConfig.multiDb
? "select * from JCR_MITEM P, JCR_MVALUE V where P.ID=V.PROPERTY_ID and
P.P_TYPE=9 and NOT EXISTS "
+ "(select * from JCR_MREF R where P.ID=R.PROPERTY_ID)"
: "select * from JCR_SITEM P, JCR_SVALUE V where P.ID=V.PROPERTY_ID and
P.CONTAINER_NAME='"
- + jdbcDataContainer.containerName
+ + jdbcDataContainer.containerConfig.containerName
+ "' and P.P_TYPE=9 and NOT EXISTS (select * from JCR_SREF R where
P.ID=R.PROPERTY_ID)", new String[]{
DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
- "Reference properties without reference records", new
PropertyRemover(jdbcDataContainer
- .getConnectionFactory(), nodeTypeManager)));
+ "Reference properties without reference records", new
PropertyRemover(
+ jdbcDataContainer.getConnectionFactory(), nodeTypeManager)));
}
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -19,13 +19,11 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.db;
import org.exoplatform.commons.utils.ClassLoading;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
-import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
@@ -47,132 +45,27 @@
protected final DataSource dbDataSource;
- protected final String dbDriver;
+ protected final JDBCDataContainerConfig containerConfig;
- protected final String dbUrl;
-
- protected final String dbUserName;
-
- protected final String dbPassword;
-
- protected final String containerName;
-
- protected final boolean multiDb;
-
- protected final ValueStoragePluginProvider valueStorageProvider;
-
- protected final int maxBufferSize;
-
- protected final File swapDirectory;
-
- protected final FileCleaner swapCleaner;
-
/**
* GenericConnectionFactory constructor.
- *
- * @param dataSource
- * - DataSource
- * @param dbDriver
- * - JDBC Driver
- * @param dbUrl
- * - JDBC URL
- * @param dbUserName
- * - database username
- * @param dbPassword
- * - database user password
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
*/
- protected GenericConnectionFactory(DataSource dataSource, String dbDriver, String
dbUrl, String dbUserName,
- String dbPassword, String containerName, boolean multiDb,
ValueStoragePluginProvider valueStorageProvider,
- int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
+ public GenericConnectionFactory(DataSource dataSource, JDBCDataContainerConfig
containerConfig)
{
-
- this.containerName = containerName;
- this.multiDb = multiDb;
- this.valueStorageProvider = valueStorageProvider;
- this.maxBufferSize = maxBufferSize;
- this.swapDirectory = swapDirectory;
- this.swapCleaner = swapCleaner;
-
+ this.containerConfig = containerConfig;
this.dbDataSource = dataSource;
- this.dbDriver = dbDriver;
- this.dbUrl = dbUrl;
- this.dbUserName = dbUserName;
- this.dbPassword = dbPassword;
}
/**
- * GenericConnectionFactory constructor.
- *
- * @param dataSource
- * - DataSource
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
+ * GenericConnectionFactory constructor with dbDriver class validation
*/
- public GenericConnectionFactory(DataSource dataSource, String containerName, boolean
multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public GenericConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
{
+ this(null, containerConfig);
- this(dataSource, null, null, null, null, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
- }
-
- /**
- * GenericConnectionFactory constructor.
- *
- * @param dbDriver
- * - JDBC Driver
- * @param dbUrl
- * - JDBC URL
- * @param dbUserName
- * - database username
- * @param dbPassword
- * - database user password
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- */
- public GenericConnectionFactory(String dbDriver, String dbUrl, String dbUserName,
String dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
- {
-
- this(null, dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
-
try
{
- ClassLoading.forName(dbDriver, this).newInstance();
+ ClassLoading.forName(this.containerConfig.dbDriver, this).newInstance();
}
catch (InstantiationException e)
{
@@ -204,14 +97,12 @@
try
{
- if (multiDb)
+ if (this.containerConfig.dbStructureType.isSimpleTable())
{
- return new MultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new MultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
- return new SingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName, valueStorageProvider,
- maxBufferSize, swapDirectory, swapCleaner);
+ return new SingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
catch (SQLException e)
@@ -228,8 +119,9 @@
try
{
Connection conn =
- dbDataSource != null ? dbDataSource.getConnection() : (dbUserName != null ?
DriverManager.getConnection(
- dbUrl, dbUserName, dbPassword) : DriverManager.getConnection(dbUrl));
+ dbDataSource != null ? dbDataSource.getConnection() :
(this.containerConfig.dbUserName != null
+ ? DriverManager.getConnection(this.containerConfig.dbUrl,
this.containerConfig.dbUserName,
+ this.containerConfig.dbPassword) :
DriverManager.getConnection(this.containerConfig.dbUrl));
if (readOnly)
{
// set this feature only if it asked
@@ -259,12 +151,12 @@
* Indicates if component support extracting data from storage using paging.
*
* @return boolean
- */
+ */
public boolean isReindexingSupport()
{
return false;
}
-
+
/**
* Indicates whether the id of the last item is needed for paging
* @return <code>true</code> if the id is needed,
<code>false</code> otherwise.
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBConnectionFactory.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBConnectionFactory.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBConnectionFactory.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -16,11 +16,9 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.db;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import java.io.File;
import java.sql.SQLException;
import javax.jcr.RepositoryException;
@@ -38,65 +36,20 @@
{
/**
- * HSQLDBConnectionFactory constructor.
- *
- * @param dataSource
- * - DataSource
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- */
- public HSQLDBConnectionFactory(DataSource dataSource, String containerName, boolean
multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ * HSQLDBConnectionFactory constructor.
+ */
+ public HSQLDBConnectionFactory(DataSource dataSource, JDBCDataContainerConfig
containerConfig)
{
-
- super(dataSource, containerName, multiDb, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dataSource, containerConfig);
}
/**
* HSQLDBConnectionFactory constructor.
- *
- *@param dataSource
- * - DataSource
- * @param dbDriver
- * - JDBC Driver
- * @param dbUrl
- * - JDBC URL
- * @param dbUserName
- * - database username
- * @param dbPassword
- * - database user password
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- * @throws RepositoryException
- * if error eccurs
*/
- public HSQLDBConnectionFactory(String dbDriver, String dbUrl, String dbUserName,
String dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ public HSQLDBConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
{
- super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ super(containerConfig);
}
/**
@@ -106,15 +59,12 @@
{
try
{
-
- if (multiDb)
+ if (this.containerConfig.dbStructureType.isSimpleTable())
{
- return new HSQLDBMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new HSQLDBMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
- return new HSQLDBSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new HSQLDBSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
catch (SQLException e)
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -16,10 +16,8 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.db;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.sql.Connection;
import java.sql.SQLException;
@@ -38,28 +36,16 @@
* HSQLDB Multidatabase JDBC Connection constructor.
*
* @param dbConnection
- * JDBC connection, shoudl be opened before
+ * JDBC connection, should be opened before
* @param readOnly
* boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName
- * Workspace Storage Container name (see configuration)
- * @param valueStorageProvider
- * External Value Storages provider
- * @param maxBufferSize
- * Maximum buffer size (see configuration)
- * @param swapDirectory
- * Swap directory File (see configuration)
- * @param swapCleaner
- * Swap cleaner (internal FileCleaner).
- * @throws SQLException
- *
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ * @param containerConfig
+ * Workspace Storage Container configuration
*/
- public HSQLDBMultiDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public HSQLDBMultiDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -71,12 +57,13 @@
super.prepareQueries();
FIND_PROPERTY_BY_NAME =
- "select V.DATA" + " from JCR_MITEM I, JCR_MVALUE V"
+ "select V.DATA" + " from " + JCR_ITEM + " I, " +
JCR_VALUE + " V"
+ " where I.PARENT_ID=? and I.I_CLASS=2 and I.NAME=? and
I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
- FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where
PARENT_ID=? and I_CLASS=1" + " order by N_ORDER_NUM";
+ FIND_NODES_BY_PARENTID =
+ "select * from " + JCR_ITEM + " where PARENT_ID=? and
I_CLASS=1" + " order by N_ORDER_NUM";
FIND_LAST_ORDER_NUMBER_BY_PARENTID =
- "select count(*), max(N_ORDER_NUM) from JCR_MITEM where PARENT_ID=? and
I_CLASS=1";
- FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + "
where PARENT_ID=? and I_CLASS=1";
- FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where
PARENT_ID=? and I_CLASS=2" + " order by ID";
+ "select count(*), max(N_ORDER_NUM) from " + JCR_ITEM + " where
PARENT_ID=? and I_CLASS=1";
+ FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from " + JCR_ITEM +
" where PARENT_ID=? and I_CLASS=1";
+ FIND_PROPERTIES_BY_PARENTID = "select * from " + JCR_ITEM + " where
PARENT_ID=? and I_CLASS=2" + " order by ID";
}
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -16,10 +16,8 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.db;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -36,31 +34,19 @@
{
/**
- * HSQLDB Singledatabase JDBC Connection constructor.
- *
- * @param dbConnection
- * JDBC connection, shoudl be opened before
- * @param readOnly
- * boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName
- * Workspace Storage Container name (see configuration)
- * @param valueStorageProvider
- * External Value Storages provider
- * @param maxBufferSize
- * Maximum buffer size (see configuration)
- * @param swapDirectory
- * Swap directory File (see configuration)
- * @param swapCleaner
- * Swap cleaner (internal FileCleaner).
- * @throws SQLException
- *
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
- */
- public HSQLDBSingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ * HSQLDB Singledatabase JDBC Connection constructor.
+ *
+ * @param dbConnection
+ * JDBC connection, should be opened before
+ * @param readOnly
+ * boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerConfig
+ * Workspace Storage Container configuration
+ */
+ public HSQLDBSingleDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -97,12 +83,16 @@
protected ResultSet findItemByName(String parentId, String name, int index) throws
SQLException
{
if (findItemByName == null)
+ {
findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
+ }
else
+ {
findItemByName.clearParameters();
+ }
findItemByName.setString(1, parentId);
- findItemByName.setString(2, containerName);
+ findItemByName.setString(2, this.containerConfig.containerName);
findItemByName.setString(3, name);
findItemByName.setInt(4, index);
@@ -116,12 +106,16 @@
protected ResultSet findPropertyByName(String parentCid, String name) throws
SQLException
{
if (findPropertyByName == null)
+ {
findPropertyByName = dbConnection.prepareStatement(FIND_PROPERTY_BY_NAME);
+ }
else
+ {
findPropertyByName.clearParameters();
+ }
findPropertyByName.setString(1, parentCid);
- findPropertyByName.setString(2, containerName);
+ findPropertyByName.setString(2, this.containerConfig.containerName);
findPropertyByName.setString(3, name);
return findPropertyByName.executeQuery();
@@ -134,12 +128,16 @@
protected ResultSet findChildNodesByParentIdentifier(String parentCid) throws
SQLException
{
if (findNodesByParentId == null)
+ {
findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
+ }
else
+ {
findNodesByParentId.clearParameters();
+ }
findNodesByParentId.setString(1, parentCid);
- findNodesByParentId.setString(2, containerName);
+ findNodesByParentId.setString(2, this.containerConfig.containerName);
return findNodesByParentId.executeQuery();
}
@@ -151,12 +149,16 @@
protected ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier)
throws SQLException
{
if (findLastOrderNumberByParentId == null)
+ {
findLastOrderNumberByParentId =
dbConnection.prepareStatement(FIND_LAST_ORDER_NUMBER_BY_PARENTID);
+ }
else
+ {
findLastOrderNumberByParentId.clearParameters();
+ }
findLastOrderNumberByParentId.setString(1, parentIdentifier);
- findLastOrderNumberByParentId.setString(2, containerName);
+ findLastOrderNumberByParentId.setString(2, this.containerConfig.containerName);
return findLastOrderNumberByParentId.executeQuery();
}
@@ -168,12 +170,16 @@
protected ResultSet findChildNodesCountByParentIdentifier(String parentCid) throws
SQLException
{
if (findNodesCountByParentId == null)
+ {
findNodesCountByParentId =
dbConnection.prepareStatement(FIND_NODES_COUNT_BY_PARENTID);
+ }
else
+ {
findNodesCountByParentId.clearParameters();
+ }
findNodesCountByParentId.setString(1, parentCid);
- findNodesCountByParentId.setString(2, containerName);
+ findNodesCountByParentId.setString(2, this.containerConfig.containerName);
return findNodesCountByParentId.executeQuery();
}
@@ -185,12 +191,16 @@
protected ResultSet findChildPropertiesByParentIdentifier(String parentCid) throws
SQLException
{
if (findPropertiesByParentId == null)
+ {
findPropertiesByParentId =
dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
+ }
else
+ {
findPropertiesByParentId.clearParameters();
+ }
findPropertiesByParentId.setString(1, parentCid);
- findPropertiesByParentId.setString(2, containerName);
+ findPropertiesByParentId.setString(2, this.containerConfig.containerName);
return findPropertiesByParentId.executeQuery();
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -23,11 +23,9 @@
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.dataflow.ValueDataConvertor;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
@@ -54,22 +52,18 @@
/**
* Multidatabase JDBC Connection constructor.
*
- * @param dbConnection JDBC connection, shoudl be opened before
- * @param readOnly, boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName Workspace Storage Container name (see configuration)
- * @param valueStorageProvider External Value Storages provider
- * @param maxBufferSize Maximum buffer size (see configuration)
- * @param swapDirectory Swap directory (see configuration)
- * @param swapCleaner Swap cleaner (internal FileCleaner).
- * @throws SQLException
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ * @param dbConnection
+ * JDBC connection, should be opened before
+ * @param readOnly
+ * boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerConfig
+ * Workspace Storage Container configuration
*/
- public MultiDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public MultiDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -96,70 +90,66 @@
@Override
protected void prepareQueries() throws SQLException
{
- JCR_PK_ITEM = "JCR_PK_MITEM";
- JCR_FK_ITEM_PARENT = "JCR_FK_MITEM_PARENT";
- JCR_IDX_ITEM_PARENT = "JCR_IDX_MITEM_PARENT";
- JCR_IDX_ITEM_PARENT_ID = "JCR_IDX_MITEM_PARENT_ID";
- JCR_PK_VALUE = "JCR_PK_MVALUE";
- JCR_FK_VALUE_PROPERTY = "JCR_FK_MVALUE_PROPERTY";
- JCR_IDX_VALUE_PROPERTY = "JCR_IDX_MVALUE_PROPERTY";
- JCR_PK_REF = "JCR_PK_MREF";
- JCR_IDX_REF_PROPERTY = "JCR_IDX_MREF_PROPERTY";
- FIND_ITEM_BY_ID = "select * from JCR_MITEM where ID=?";
+ FIND_ITEM_BY_ID = "select * from " + JCR_ITEM + " where ID=?";
FIND_ITEM_BY_NAME =
- "select * from JCR_MITEM" + " where PARENT_ID=? and NAME=? and
I_INDEX=? order by I_CLASS, VERSION DESC";
+ "select * from " + JCR_ITEM + " where PARENT_ID=? and NAME=? and
I_INDEX=? order by I_CLASS, VERSION DESC";
FIND_PROPERTY_BY_NAME =
- "select V.DATA" + " from JCR_MITEM I, JCR_MVALUE V"
+ "select V.DATA" + " from " + JCR_ITEM + " I, " +
JCR_VALUE + " V"
+ " where I.I_CLASS=2 and I.PARENT_ID=? and I.NAME=? and
I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
FIND_REFERENCES =
- "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED,
P.NAME" + " from JCR_MREF R, JCR_MITEM P"
- + " where R.NODE_ID=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2";
+ "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED,
P.NAME" + " from " + JCR_REF + " R, "
+ + JCR_ITEM + " P" + " where R.NODE_ID=? and P.ID=R.PROPERTY_ID
and P.I_CLASS=2";
FIND_VALUES_BY_PROPERTYID =
- "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_MVALUE where
PROPERTY_ID=? order by ORDER_NUM";
+ "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from " + JCR_VALUE
+ + " where PROPERTY_ID=? order by ORDER_NUM";
- FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from
JCR_MVALUE where PROPERTY_ID=?";
+ FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID =
+ "select distinct STORAGE_DESC from " + JCR_VALUE + " where
PROPERTY_ID=?";
FIND_VALUE_BY_PROPERTYID_OREDERNUMB =
- "select DATA, STORAGE_DESC from JCR_MVALUE where PROPERTY_ID=? and
ORDER_NUM=?";
+ "select DATA, STORAGE_DESC from " + JCR_VALUE + " where
PROPERTY_ID=? and ORDER_NUM=?";
- FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where
I_CLASS=1 and PARENT_ID=?" + " order by N_ORDER_NUM";
+ FIND_NODES_BY_PARENTID =
+ "select * from " + JCR_ITEM + " where I_CLASS=1 and
PARENT_ID=?" + " order by N_ORDER_NUM";
FIND_LAST_ORDER_NUMBER_BY_PARENTID =
- "select count(*), max(N_ORDER_NUM) from JCR_MITEM where I_CLASS=1 and
PARENT_ID=?";
+ "select count(*), max(N_ORDER_NUM) from " + JCR_ITEM + " where
I_CLASS=1 and PARENT_ID=?";
- FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + "
where I_CLASS=1 and PARENT_ID=?";
+ FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from " + JCR_ITEM +
" where I_CLASS=1 and PARENT_ID=?";
- FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where
I_CLASS=2 and PARENT_ID=?" + " order by ID";
+ FIND_PROPERTIES_BY_PARENTID = "select * from " + JCR_ITEM + " where
I_CLASS=2 and PARENT_ID=?" + " order by ID";
FIND_MAX_PROPERTY_VERSIONS =
"select max(VERSION) FROM JCR_MITEM WHERE PARENT_ID=? and NAME=? and
I_INDEX=? and I_CLASS=2";
INSERT_NODE =
- "insert into JCR_MITEM(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX,
N_ORDER_NUM) VALUES(?,?,?,?,"
+ "insert into " + JCR_ITEM + "(ID, PARENT_ID, NAME, VERSION,
I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,"
+ I_CLASS_NODE + ",?,?)";
INSERT_PROPERTY =
- "insert into JCR_MITEM(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX,
P_TYPE, P_MULTIVALUED) VALUES(?,?,?,?,"
+ "insert into " + JCR_ITEM
+ + "(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, P_TYPE,
P_MULTIVALUED) VALUES(?,?,?,?,"
+ I_CLASS_PROPERTY + ",?,?,?)";
- INSERT_VALUE = "insert into JCR_MVALUE(DATA, ORDER_NUM, PROPERTY_ID,
STORAGE_DESC) VALUES(?,?,?,?)";
- INSERT_REF = "insert into JCR_MREF(NODE_ID, PROPERTY_ID, ORDER_NUM)
VALUES(?,?,?)";
+ INSERT_VALUE = "insert into " + JCR_VALUE + "(DATA, ORDER_NUM,
PROPERTY_ID, STORAGE_DESC) VALUES(?,?,?,?)";
+ INSERT_REF = "insert into " + JCR_REF + "(NODE_ID, PROPERTY_ID,
ORDER_NUM) VALUES(?,?,?)";
- RENAME_NODE = "update JCR_MITEM set PARENT_ID=?, NAME =?, VERSION=?, I_INDEX
=?, N_ORDER_NUM =? where ID=?";
+ RENAME_NODE =
+ "update " + JCR_ITEM + " set PARENT_ID=?, NAME =?, VERSION=?,
I_INDEX =?, N_ORDER_NUM =? where ID=?";
- UPDATE_NODE = "update JCR_MITEM set VERSION=?, I_INDEX=?, N_ORDER_NUM=? where
ID=?";
- UPDATE_PROPERTY = "update JCR_MITEM set VERSION=?, P_TYPE=? where ID=?";
- //UPDATE_VALUE = "update JCR_MVALUE set DATA=?, STORAGE_DESC=? where
PROPERTY_ID=?, ORDER_NUM=?";
+ UPDATE_NODE = "update " + JCR_ITEM + " set VERSION=?, I_INDEX=?,
N_ORDER_NUM=? where ID=?";
+ UPDATE_PROPERTY = "update " + JCR_ITEM + " set VERSION=?, P_TYPE=?
where ID=?";
+ //UPDATE_VALUE = "update "+JCR_VALUE+" set DATA=?, STORAGE_DESC=?
where PROPERTY_ID=?, ORDER_NUM=?";
- DELETE_ITEM = "delete from JCR_MITEM where ID=?";
- DELETE_VALUE = "delete from JCR_MVALUE where PROPERTY_ID=?";
- DELETE_REF = "delete from JCR_MREF where PROPERTY_ID=?";
+ DELETE_ITEM = "delete from " + JCR_ITEM + " where ID=?";
+ DELETE_VALUE = "delete from " + JCR_VALUE + " where
PROPERTY_ID=?";
+ DELETE_REF = "delete from " + JCR_REF + " where
PROPERTY_ID=?";
- FIND_NODES_COUNT = "select count(*) from JCR_MITEM I where I.I_CLASS=1";
+ FIND_NODES_COUNT = "select count(*) from " + JCR_ITEM + " I where
I.I_CLASS=1";
}
/**
@@ -169,13 +159,17 @@
protected int addNodeRecord(NodeData data) throws SQLException
{
if (insertNode == null)
+ {
insertNode = dbConnection.prepareStatement(INSERT_NODE);
+ }
else
+ {
insertNode.clearParameters();
+ }
insertNode.setString(1, data.getIdentifier());
- insertNode.setString(2, data.getParentIdentifier() == null ?
Constants.ROOT_PARENT_UUID : data
- .getParentIdentifier());
+ insertNode.setString(2,
+ data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID :
data.getParentIdentifier());
insertNode.setString(3, data.getQPath().getName().getAsString());
insertNode.setInt(4, data.getPersistedVersion());
insertNode.setInt(5, data.getQPath().getIndex());
@@ -190,9 +184,13 @@
protected int addPropertyRecord(PropertyData data) throws SQLException
{
if (insertProperty == null)
+ {
insertProperty = dbConnection.prepareStatement(INSERT_PROPERTY);
+ }
else
+ {
insertProperty.clearParameters();
+ }
insertProperty.setString(1, data.getIdentifier());
insertProperty.setString(2, data.getParentIdentifier());
@@ -212,12 +210,18 @@
protected int addReference(PropertyData data) throws SQLException, IOException
{
if (insertReference == null)
+ {
insertReference = dbConnection.prepareStatement(INSERT_REF);
+ }
else
+ {
insertReference.clearParameters();
+ }
if (data.getQPath().getAsString().indexOf("versionableUuid") > 0)
+ {
LOG.info("add ref versionableUuid " + data.getQPath().getAsString());
+ }
List<ValueData> values = data.getValues();
int added = 0;
@@ -242,9 +246,13 @@
protected int deleteReference(String propertyIdentifier) throws SQLException
{
if (deleteReference == null)
+ {
deleteReference = dbConnection.prepareStatement(DELETE_REF);
+ }
else
+ {
deleteReference.clearParameters();
+ }
deleteReference.setString(1, propertyIdentifier);
return deleteReference.executeUpdate();
@@ -257,9 +265,13 @@
protected int deleteItemByIdentifier(String identifier) throws SQLException
{
if (deleteItem == null)
+ {
deleteItem = dbConnection.prepareStatement(DELETE_ITEM);
+ }
else
+ {
deleteItem.clearParameters();
+ }
deleteItem.setString(1, identifier);
return deleteItem.executeUpdate();
@@ -272,9 +284,13 @@
protected int updateNodeByIdentifier(int version, int index, int orderNumb, String
identifier) throws SQLException
{
if (updateNode == null)
+ {
updateNode = dbConnection.prepareStatement(UPDATE_NODE);
+ }
else
+ {
updateNode.clearParameters();
+ }
updateNode.setInt(1, version);
updateNode.setInt(2, index);
@@ -290,9 +306,13 @@
protected int updatePropertyByIdentifier(int version, int type, String identifier)
throws SQLException
{
if (updateProperty == null)
+ {
updateProperty = dbConnection.prepareStatement(UPDATE_PROPERTY);
+ }
else
+ {
updateProperty.clearParameters();
+ }
updateProperty.setInt(1, version);
updateProperty.setInt(2, type);
@@ -307,9 +327,13 @@
protected ResultSet findItemByName(String parentId, String name, int index) throws
SQLException
{
if (findItemByName == null)
+ {
findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
+ }
else
+ {
findItemByName.clearParameters();
+ }
findItemByName.setString(1, parentId);
findItemByName.setString(2, name);
@@ -324,9 +348,13 @@
protected ResultSet findPropertyByName(String parentId, String name) throws
SQLException
{
if (findPropertyByName == null)
+ {
findPropertyByName = dbConnection.prepareStatement(FIND_PROPERTY_BY_NAME);
+ }
else
+ {
findPropertyByName.clearParameters();
+ }
findPropertyByName.setString(1, parentId);
findPropertyByName.setString(2, name);
@@ -340,9 +368,13 @@
protected ResultSet findItemByIdentifier(String identifier) throws SQLException
{
if (findItemById == null)
+ {
findItemById = dbConnection.prepareStatement(FIND_ITEM_BY_ID);
+ }
else
+ {
findItemById.clearParameters();
+ }
findItemById.setString(1, identifier);
return findItemById.executeQuery();
@@ -355,9 +387,13 @@
protected ResultSet findReferences(String nodeIdentifier) throws SQLException
{
if (findReferences == null)
+ {
findReferences = dbConnection.prepareStatement(FIND_REFERENCES);
+ }
else
+ {
findReferences.clearParameters();
+ }
findReferences.setString(1, nodeIdentifier);
return findReferences.executeQuery();
@@ -370,9 +406,13 @@
protected ResultSet findChildNodesByParentIdentifier(String parentIdentifier) throws
SQLException
{
if (findNodesByParentId == null)
+ {
findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
+ }
else
+ {
findNodesByParentId.clearParameters();
+ }
findNodesByParentId.setString(1, parentIdentifier);
return findNodesByParentId.executeQuery();
@@ -385,9 +425,13 @@
protected ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier)
throws SQLException
{
if (findLastOrderNumberByParentId == null)
+ {
findLastOrderNumberByParentId =
dbConnection.prepareStatement(FIND_LAST_ORDER_NUMBER_BY_PARENTID);
+ }
else
+ {
findLastOrderNumberByParentId.clearParameters();
+ }
findLastOrderNumberByParentId.setString(1, parentIdentifier);
return findLastOrderNumberByParentId.executeQuery();
@@ -400,9 +444,13 @@
protected ResultSet findChildNodesCountByParentIdentifier(String parentIdentifier)
throws SQLException
{
if (findNodesCountByParentId == null)
+ {
findNodesCountByParentId =
dbConnection.prepareStatement(FIND_NODES_COUNT_BY_PARENTID);
+ }
else
+ {
findNodesCountByParentId.clearParameters();
+ }
findNodesCountByParentId.setString(1, parentIdentifier);
return findNodesCountByParentId.executeQuery();
@@ -415,9 +463,13 @@
protected ResultSet findChildPropertiesByParentIdentifier(String parentIdentifier)
throws SQLException
{
if (findPropertiesByParentId == null)
+ {
findPropertiesByParentId =
dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
+ }
else
+ {
findPropertiesByParentId.clearParameters();
+ }
findPropertiesByParentId.setString(1, parentIdentifier);
return findPropertiesByParentId.executeQuery();
@@ -443,9 +495,13 @@
{
if (insertValue == null)
+ {
insertValue = dbConnection.prepareStatement(INSERT_VALUE);
+ }
else
+ {
insertValue.clearParameters();
+ }
if (stream == null)
{
@@ -471,9 +527,13 @@
protected int deleteValueData(String cid) throws SQLException
{
if (deleteValue == null)
+ {
deleteValue = dbConnection.prepareStatement(DELETE_VALUE);
+ }
else
+ {
deleteValue.clearParameters();
+ }
deleteValue.setString(1, cid);
return deleteValue.executeUpdate();
@@ -486,9 +546,13 @@
protected ResultSet findValuesByPropertyId(String cid) throws SQLException
{
if (findValuesByPropertyId == null)
+ {
findValuesByPropertyId =
dbConnection.prepareStatement(FIND_VALUES_BY_PROPERTYID);
+ }
else
+ {
findValuesByPropertyId.clearParameters();
+ }
findValuesByPropertyId.setString(1, cid);
return findValuesByPropertyId.executeQuery();
@@ -501,9 +565,13 @@
protected ResultSet findValueByPropertyIdOrderNumber(String cid, int orderNumb) throws
SQLException
{
if (findValueByPropertyIdOrderNumber == null)
+ {
findValueByPropertyIdOrderNumber =
dbConnection.prepareStatement(FIND_VALUE_BY_PROPERTYID_OREDERNUMB);
+ }
else
+ {
findValueByPropertyIdOrderNumber.clearParameters();
+ }
findValueByPropertyIdOrderNumber.setString(1, cid);
findValueByPropertyIdOrderNumber.setInt(2, orderNumb);
@@ -517,12 +585,16 @@
protected int renameNode(NodeData data) throws SQLException
{
if (renameNode == null)
+ {
renameNode = dbConnection.prepareStatement(RENAME_NODE);
+ }
else
+ {
renameNode.clearParameters();
+ }
- renameNode.setString(1, data.getParentIdentifier() == null ?
Constants.ROOT_PARENT_UUID : data
- .getParentIdentifier());
+ renameNode.setString(1,
+ data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID :
data.getParentIdentifier());
renameNode.setString(2, data.getQPath().getName().getAsString());
renameNode.setInt(3, data.getPersistedVersion());
renameNode.setInt(4, data.getQPath().getIndex());
@@ -538,10 +610,14 @@
protected ResultSet findValuesStorageDescriptorsByPropertyId(String cid) throws
SQLException
{
if (findValuesStorageDescriptorsByPropertyId == null)
+ {
findValuesStorageDescriptorsByPropertyId =
dbConnection.prepareStatement(FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID);
+ }
else
+ {
findValuesStorageDescriptorsByPropertyId.clearParameters();
+ }
findValuesStorageDescriptorsByPropertyId.setString(1, cid);
return findValuesStorageDescriptorsByPropertyId.executeQuery();
@@ -568,12 +644,13 @@
try
{
removeValuesStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_MVALUE WHERE PROPERTY_ID
IN "
- + "(SELECT ID FROM JCR_MITEM WHERE NAME =
'[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ dbConnection.prepareStatement("DELETE FROM " + JCR_VALUE + "
WHERE PROPERTY_ID IN " + "(SELECT ID FROM "
+ + JCR_ITEM + " WHERE NAME =
'[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
removeItemsStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_MITEM WHERE NAME =
'[http://www.jcp.org/jcr/1.0]lockIsDeep'"
+ dbConnection.prepareStatement("DELETE FROM " + JCR_ITEM
+ + " WHERE NAME =
'[http://www.jcp.org/jcr/1.0]lockIsDeep'"
+ " OR NAME =
'[http://www.jcp.org/jcr/1.0]lockOwner'");
removeValuesStatement.executeUpdate();
@@ -631,13 +708,12 @@
try
{
removeValuesStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_MVALUE WHERE PROPERTY_ID
IN"
- + " (SELECT ID FROM JCR_MITEM WHERE PARENT_ID=? AND"
- + " (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep'
OR"
+ dbConnection.prepareStatement("DELETE FROM " + JCR_VALUE + "
WHERE PROPERTY_ID IN" + " (SELECT ID FROM "
+ + JCR_ITEM + " WHERE PARENT_ID=? AND" + " (NAME =
'[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'))");
removeItemsStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_MITEM WHERE PARENT_ID=?
AND"
+ dbConnection.prepareStatement("DELETE FROM " + JCR_ITEM + "
WHERE PARENT_ID=? AND"
+ " (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep'
OR"
+ " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLConnectionFactory.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLConnectionFactory.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLConnectionFactory.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -18,11 +18,9 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.db;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import java.io.File;
import java.sql.SQLException;
import javax.jcr.RepositoryException;
@@ -41,64 +39,20 @@
/**
* MySQLConnectionFactory constructor.
- *
- *@param dataSource
- * - DataSource
- * @param dbDriver
- * - JDBC Driver
- * @param dbUrl
- * - JDBC URL
- * @param dbUserName
- * - database username
- * @param dbPassword
- * - database user password
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- * @throws RepositoryException
- * if error eccurs
*/
- public MySQLConnectionFactory(String dbDriver, String dbUrl, String dbUserName, String
dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ public MySQLConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
{
- super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ super(containerConfig);
}
/**
* MySQLConnectionFactory constructor.
- *
- * @param dataSource
- * - DataSource
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
*/
- public MySQLConnectionFactory(DataSource dbDataSource, String containerName, boolean
multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public MySQLConnectionFactory(DataSource dbDataSource, JDBCDataContainerConfig
containerConfig)
{
- super(dbDataSource, containerName, multiDb, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbDataSource, containerConfig);
}
/**
@@ -109,15 +63,12 @@
{
try
{
-
- if (multiDb)
+ if (this.containerConfig.dbStructureType.isSimpleTable())
{
- return new MySQLMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new MySQLMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
- return new MySQLSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new MySQLSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
catch (SQLException e)
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLMultiDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLMultiDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLMultiDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -20,10 +20,8 @@
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -43,29 +41,17 @@
* MySQL Multidatabase JDBC Connection constructor.
*
* @param dbConnection
- * JDBC connection, shoudl be opened before
+ * JDBC connection, should be opened before
* @param readOnly
* boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName
- * Workspace Storage Container name (see configuration)
- * @param valueStorageProvider
- * External Value Storages provider
- * @param maxBufferSize
- * Maximum buffer size (see configuration)
- * @param swapDirectory
- * Swap directory File (see configuration)
- * @param swapCleaner
- * Swap cleaner (internal FileCleaner).
- * @throws SQLException
- *
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ * @param containerConfig
+ * Workspace Storage Container configuration
*/
- public MySQLMultiDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public MySQLMultiDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -81,7 +67,9 @@
try
{
if (!item.next())
+ {
throw new SQLException("Parent is not found. Behaviour of " +
JCR_FK_ITEM_PARENT);
+ }
}
finally
{
@@ -111,7 +99,9 @@
try
{
if (!item.next())
+ {
throw new SQLException("Parent is not found. Behaviour of " +
JCR_FK_ITEM_PARENT);
+ }
}
finally
{
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLSingleDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLSingleDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLSingleDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -20,10 +20,8 @@
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -43,29 +41,17 @@
* MySQL Singledatabase JDBC Connection constructor.
*
* @param dbConnection
- * JDBC connection, shoudl be opened before
+ * JDBC connection, should be opened before
* @param readOnly
* boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName
- * Workspace Storage Container name (see configuration)
- * @param valueStorageProvider
- * External Value Storages provider
- * @param maxBufferSize
- * Maximum buffer size (see configuration)
- * @param swapDirectory
- * Swap directory File (see configuration)
- * @param swapCleaner
- * Swap cleaner (internal FileCleaner).
- * @throws SQLException
- *
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ * @param containerConfig
+ * Workspace Storage Container configuration
*/
- public MySQLSingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public MySQLSingleDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -81,7 +67,9 @@
try
{
if (!item.next())
+ {
throw new SQLException("Parent is not found. Behaviour of " +
JCR_FK_ITEM_PARENT);
+ }
}
finally
{
@@ -111,7 +99,9 @@
try
{
if (!item.next())
+ {
throw new SQLException("Parent is not found. Behaviour of " +
JCR_FK_ITEM_PARENT);
+ }
}
finally
{
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OracleConnectionFactory.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OracleConnectionFactory.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OracleConnectionFactory.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -19,10 +19,8 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.db;
import org.exoplatform.commons.utils.ClassLoading;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -57,33 +55,8 @@
/**
* OracleConnectionFactory constructor. For CLI interface ONLY!
- *
- * @param dbDriver
- * - JDBC Driver
- * @param dbUrl
- * - JDBC URL
- * @param dbUserName
- * - database username
- * @param dbPassword
- * - database user password
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- * @throws RepositoryException
- * if error occurs
*/
- public OracleConnectionFactory(String dbDriver, String dbUrl, String dbUserName,
String dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ public OracleConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
{
// ;D:\Devel\oracle_instantclient_10_2\;C:\oracle\ora92\bin;
@@ -111,8 +84,7 @@
* (OracleOCIConnectionPool.java:893)
*/
- super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ super(containerConfig);
Object cds = null;
try
@@ -130,13 +102,13 @@
prop.setProperty("AbandonedConnectionTimeout",
String.valueOf(CONNCACHE_ABADONDED_TIMEOUT));
Method setURL = cds.getClass().getMethod("setURL", new
Class[]{String.class});
- setURL.invoke(cds, new Object[]{this.dbUrl});
+ setURL.invoke(cds, new Object[]{this.containerConfig.dbUrl});
Method setUser = cds.getClass().getMethod("setUser", new
Class[]{String.class});
- setUser.invoke(cds, new Object[]{this.dbUserName});
+ setUser.invoke(cds, new Object[]{this.containerConfig.dbUserName});
Method setPassword = cds.getClass().getMethod("setPassword", new
Class[]{String.class});
- setPassword.invoke(cds, new Object[]{this.dbPassword});
+ setPassword.invoke(cds, new Object[]{this.containerConfig.dbPassword});
Method setConnectionCachingEnabled =
cds.getClass().getMethod("setConnectionCachingEnabled", new
Class[]{boolean.class});
@@ -147,7 +119,7 @@
setConnectionCacheProperties.invoke(cds, new Object[]{prop});
Method setConnectionCacheName =
cds.getClass().getMethod("setConnectionCacheName", new Class[]{String.class});
- setConnectionCacheName.invoke(cds, new Object[]{"EXOJCR_OCI__" +
containerName});
+ setConnectionCacheName.invoke(cds, new Object[]{"EXOJCR_OCI__" +
containerConfig.containerName});
}
catch (Throwable e)
@@ -160,9 +132,13 @@
}
err.append(". Standard JDBC DriverManager will be used for connections
opening.");
if (log.isDebugEnabled())
+ {
log.warn(err, e);
+ }
else
+ {
log.warn(err);
+ }
}
this.ociDataSource = cds; // actually instance of javax.sql.DataSource
}
@@ -174,6 +150,7 @@
public Connection getJdbcConnection(boolean readOnly) throws RepositoryException
{
if (ociDataSource != null)
+ {
try
{
Connection conn = getCachedConnection();
@@ -190,6 +167,7 @@
{
throw new RepositoryException("Oracle OCI cached connection open error
" + e, e);
}
+ }
return super.getJdbcConnection(readOnly);
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OraclePoolConnectionFactory.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OraclePoolConnectionFactory.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OraclePoolConnectionFactory.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -19,10 +19,8 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.db;
import org.exoplatform.commons.utils.ClassLoading;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -52,33 +50,8 @@
/**
* OraclePoolConnectionFactory constructor. For CLI interface ONLY!
- *
- * @param dbDriver
- * - JDBC Driver
- * @param dbUrl
- * - JDBC URL
- * @param dbUserName
- * - database username
- * @param dbPassword
- * - database user password
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- * @throws RepositoryException
- * if error occurs
*/
- public OraclePoolConnectionFactory(String dbDriver, String dbUrl, String dbUserName,
String dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ public OraclePoolConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
{
// ;D:\Devel\oracle_instantclient_10_2\;C:\oracle\ora92\bin;
@@ -106,8 +79,7 @@
* (OracleOCIConnectionPool.java:893)
*/
- super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ super(containerConfig);
Object cpool = null;
try
@@ -116,7 +88,9 @@
Constructor<?> cpoolConstructor =
cpoolClass.getConstructor(new Class[]{String.class, String.class,
String.class, Properties.class});
- cpool = cpoolConstructor.newInstance(new Object[]{this.dbUserName,
this.dbPassword, this.dbUrl, null});
+ cpool =
+ cpoolConstructor.newInstance(new Object[]{this.containerConfig.dbUserName,
this.containerConfig.dbPassword,
+ this.containerConfig.dbUrl, null});
Method setConnectionCachingEnabled =
cpool.getClass().getMethod("setConnectionCachingEnabled", new
Class[]{boolean.class});
setConnectionCachingEnabled.invoke(cpool, new Object[]{true});
@@ -124,16 +98,20 @@
catch (Throwable e)
{
cpool = null;
- StringBuilder err = new StringBuilder("Oracle OCI connection pool is
unavailable due to error ").append(e);
+ StringBuilder err = new StringBuilder("Oracle OCI connection pool is
unavailable due to error ").append(e);
if (e.getCause() != null)
{
err.append(" (").append(e.getCause()).append(")");
}
err.append(". Standard JDBC DriverManager will be used for connections
opening.");
if (log.isDebugEnabled())
+ {
log.warn(err, e);
+ }
else
+ {
log.warn(err);
+ }
}
this.ociPool = cpool;
@@ -146,9 +124,13 @@
catch (Throwable e)
{
if (log.isDebugEnabled())
+ {
log.warn("Oracle OCI connection pool configuration error " + e,
e);
+ }
else
+ {
log.warn("Oracle OCI connection pool configuration error " + e);
+ }
}
}
@@ -159,6 +141,7 @@
public Connection getJdbcConnection(boolean readOnly) throws RepositoryException
{
if (ociPool != null)
+ {
try
{
Connection conn = getPoolConnection();
@@ -175,6 +158,7 @@
{
throw new RepositoryException("Oracle OCI pool connection open error
" + e, e);
}
+ }
return super.getJdbcConnection(readOnly);
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -22,11 +22,9 @@
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
@@ -52,22 +50,18 @@
/**
* Singledatabase JDBC Connection constructor.
*
- * @param dbConnection JDBC connection, shoudl be opened before
- * @param readOnly, boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName Workspace Storage Container name (see configuration)
- * @param valueStorageProvider External Value Storages provider
- * @param maxBufferSize Maximum buffer size (see configuration)
- * @param swapDirectory Swap directory (see configuration)
- * @param swapCleaner Swap cleaner (internal FileCleaner).
- * @throws SQLException in case of database error
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ * @param dbConnection
+ * JDBC connection, should be opened before
+ * @param readOnly
+ * boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerConfig
+ * Workspace Storage Container configuration
*/
- public SingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public SingleDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -76,7 +70,7 @@
@Override
protected String getInternalId(final String identifier)
{
- return containerName + identifier;
+ return this.containerConfig.containerName + identifier;
}
/**
@@ -86,10 +80,12 @@
protected String getIdentifier(final String internalId)
{
- if (internalId == null) // possible for root parent
+ if (internalId == null)
+ {
return null;
+ }
- return internalId.substring(containerName.length());
+ return internalId.substring(this.containerConfig.containerName.length());
}
/**
@@ -99,16 +95,6 @@
protected void prepareQueries() throws SQLException
{
- JCR_PK_ITEM = "JCR_PK_SITEM";
- JCR_FK_ITEM_PARENT = "JCR_FK_SITEM_PARENT";
- JCR_IDX_ITEM_PARENT = "JCR_IDX_SITEM_PARENT";
- JCR_IDX_ITEM_PARENT_ID = "JCR_IDX_SITEM_PARENT_ID";
- JCR_PK_VALUE = "JCR_PK_SVALUE";
- JCR_FK_VALUE_PROPERTY = "JCR_FK_SVALUE_PROPERTY";
- JCR_IDX_VALUE_PROPERTY = "JCR_IDX_SVALUE_PROPERTY";
- JCR_PK_REF = "JCR_PK_SREF";
- JCR_IDX_REF_PROPERTY = "JCR_IDX_SREF_PROPERTY";
-
FIND_ITEM_BY_ID = "select * from JCR_SITEM where ID=?";
FIND_ITEM_BY_NAME =
@@ -178,16 +164,20 @@
protected int addNodeRecord(NodeData data) throws SQLException
{
if (insertNode == null)
+ {
insertNode = dbConnection.prepareStatement(INSERT_NODE);
+ }
else
+ {
insertNode.clearParameters();
+ }
insertNode.setString(1, getInternalId(data.getIdentifier()));
// if root then parent identifier equals space string
insertNode.setString(2, data.getParentIdentifier() == null ?
Constants.ROOT_PARENT_UUID : getInternalId(data
.getParentIdentifier()));
insertNode.setString(3, data.getQPath().getName().getAsString());
- insertNode.setString(4, containerName);
+ insertNode.setString(4, this.containerConfig.containerName);
insertNode.setInt(5, data.getPersistedVersion());
insertNode.setInt(6, data.getQPath().getIndex());
insertNode.setInt(7, data.getOrderNumber());
@@ -201,14 +191,18 @@
protected int addPropertyRecord(PropertyData data) throws SQLException
{
if (insertProperty == null)
+ {
insertProperty = dbConnection.prepareStatement(INSERT_PROPERTY);
+ }
else
+ {
insertProperty.clearParameters();
+ }
insertProperty.setString(1, getInternalId(data.getIdentifier()));
insertProperty.setString(2, getInternalId(data.getParentIdentifier()));
insertProperty.setString(3, data.getQPath().getName().getAsString());
- insertProperty.setString(4, containerName);
+ insertProperty.setString(4, this.containerConfig.containerName);
insertProperty.setInt(5, data.getPersistedVersion());
insertProperty.setInt(6, data.getQPath().getIndex());
insertProperty.setInt(7, data.getType());
@@ -224,9 +218,13 @@
protected int addReference(PropertyData data) throws SQLException, IOException
{
if (insertReference == null)
+ {
insertReference = dbConnection.prepareStatement(INSERT_REF);
+ }
else
+ {
insertReference.clearParameters();
+ }
List<ValueData> values = data.getValues();
int added = 0;
@@ -250,9 +248,13 @@
protected int deleteReference(String propertyCid) throws SQLException
{
if (deleteReference == null)
+ {
deleteReference = dbConnection.prepareStatement(DELETE_REF);
+ }
else
+ {
deleteReference.clearParameters();
+ }
deleteReference.setString(1, propertyCid);
return deleteReference.executeUpdate();
@@ -265,9 +267,13 @@
protected int deleteItemByIdentifier(String cid) throws SQLException
{
if (deleteItem == null)
+ {
deleteItem = dbConnection.prepareStatement(DELETE_ITEM);
+ }
else
+ {
deleteItem.clearParameters();
+ }
deleteItem.setString(1, cid);
return deleteItem.executeUpdate();
@@ -280,11 +286,15 @@
protected ResultSet findChildNodesByParentIdentifier(String parentCid) throws
SQLException
{
if (findNodesByParentId == null)
+ {
findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
+ }
else
+ {
findNodesByParentId.clearParameters();
+ }
- findNodesByParentId.setString(1, containerName);
+ findNodesByParentId.setString(1, this.containerConfig.containerName);
findNodesByParentId.setString(2, parentCid);
return findNodesByParentId.executeQuery();
}
@@ -296,11 +306,15 @@
protected ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier)
throws SQLException
{
if (findLastOrderNumberByParentId == null)
+ {
findLastOrderNumberByParentId =
dbConnection.prepareStatement(FIND_LAST_ORDER_NUMBER_BY_PARENTID);
+ }
else
+ {
findLastOrderNumberByParentId.clearParameters();
+ }
- findLastOrderNumberByParentId.setString(1, containerName);
+ findLastOrderNumberByParentId.setString(1, this.containerConfig.containerName);
findLastOrderNumberByParentId.setString(2, parentIdentifier);
return findLastOrderNumberByParentId.executeQuery();
}
@@ -312,11 +326,15 @@
protected ResultSet findChildNodesCountByParentIdentifier(String parentCid) throws
SQLException
{
if (findNodesCountByParentId == null)
+ {
findNodesCountByParentId =
dbConnection.prepareStatement(FIND_NODES_COUNT_BY_PARENTID);
+ }
else
+ {
findNodesCountByParentId.clearParameters();
+ }
- findNodesCountByParentId.setString(1, containerName);
+ findNodesCountByParentId.setString(1, this.containerConfig.containerName);
findNodesCountByParentId.setString(2, parentCid);
return findNodesCountByParentId.executeQuery();
}
@@ -328,11 +346,15 @@
protected ResultSet findChildPropertiesByParentIdentifier(String parentCid) throws
SQLException
{
if (findPropertiesByParentId == null)
+ {
findPropertiesByParentId =
dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
+ }
else
+ {
findPropertiesByParentId.clearParameters();
+ }
- findPropertiesByParentId.setString(1, containerName);
+ findPropertiesByParentId.setString(1, this.containerConfig.containerName);
findPropertiesByParentId.setString(2, parentCid);
return findPropertiesByParentId.executeQuery();
}
@@ -344,11 +366,15 @@
protected ResultSet findItemByName(String parentId, String name, int index) throws
SQLException
{
if (findItemByName == null)
+ {
findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
+ }
else
+ {
findItemByName.clearParameters();
+ }
- findItemByName.setString(1, containerName);
+ findItemByName.setString(1, this.containerConfig.containerName);
findItemByName.setString(2, parentId);
findItemByName.setString(3, name);
findItemByName.setInt(4, index);
@@ -362,11 +388,15 @@
protected ResultSet findPropertyByName(String parentCid, String name) throws
SQLException
{
if (findPropertyByName == null)
+ {
findPropertyByName = dbConnection.prepareStatement(FIND_PROPERTY_BY_NAME);
+ }
else
+ {
findPropertyByName.clearParameters();
+ }
- findPropertyByName.setString(1, containerName);
+ findPropertyByName.setString(1, this.containerConfig.containerName);
findPropertyByName.setString(2, parentCid);
findPropertyByName.setString(3, name);
return findPropertyByName.executeQuery();
@@ -379,9 +409,13 @@
protected ResultSet findItemByIdentifier(String cid) throws SQLException
{
if (findItemById == null)
+ {
findItemById = dbConnection.prepareStatement(FIND_ITEM_BY_ID);
+ }
else
+ {
findItemById.clearParameters();
+ }
findItemById.setString(1, cid);
return findItemById.executeQuery();
@@ -394,12 +428,16 @@
protected ResultSet findReferences(String cid) throws SQLException
{
if (findReferences == null)
+ {
findReferences = dbConnection.prepareStatement(FIND_REFERENCES);
+ }
else
+ {
findReferences.clearParameters();
+ }
findReferences.setString(1, cid);
- findReferences.setString(2, containerName);
+ findReferences.setString(2, this.containerConfig.containerName);
return findReferences.executeQuery();
}
@@ -410,9 +448,13 @@
protected int updateNodeByIdentifier(int version, int index, int orderNumb, String
cid) throws SQLException
{
if (updateNode == null)
+ {
updateNode = dbConnection.prepareStatement(UPDATE_NODE);
+ }
else
+ {
updateNode.clearParameters();
+ }
updateNode.setInt(1, version);
updateNode.setInt(2, index);
@@ -428,9 +470,13 @@
protected int updatePropertyByIdentifier(int version, int type, String cid) throws
SQLException
{
if (updateProperty == null)
+ {
updateProperty = dbConnection.prepareStatement(UPDATE_PROPERTY);
+ }
else
+ {
updateProperty.clearParameters();
+ }
updateProperty.setInt(1, version);
updateProperty.setInt(2, type);
@@ -458,9 +504,13 @@
{
if (insertValue == null)
+ {
insertValue = dbConnection.prepareStatement(INSERT_VALUE);
+ }
else
+ {
insertValue.clearParameters();
+ }
if (stream == null)
{
@@ -486,9 +536,13 @@
protected int deleteValueData(String cid) throws SQLException
{
if (deleteValue == null)
+ {
deleteValue = dbConnection.prepareStatement(DELETE_VALUE);
+ }
else
+ {
deleteValue.clearParameters();
+ }
deleteValue.setString(1, cid);
return deleteValue.executeUpdate();
@@ -501,9 +555,13 @@
protected ResultSet findValuesByPropertyId(String cid) throws SQLException
{
if (findValuesByPropertyId == null)
+ {
findValuesByPropertyId =
dbConnection.prepareStatement(FIND_VALUES_BY_PROPERTYID);
+ }
else
+ {
findValuesByPropertyId.clearParameters();
+ }
findValuesByPropertyId.setString(1, cid);
return findValuesByPropertyId.executeQuery();
@@ -516,10 +574,14 @@
protected ResultSet findValuesStorageDescriptorsByPropertyId(String cid) throws
SQLException
{
if (findValuesStorageDescriptorsByPropertyId == null)
+ {
findValuesStorageDescriptorsByPropertyId =
dbConnection.prepareStatement(FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID);
+ }
else
+ {
findValuesStorageDescriptorsByPropertyId.clearParameters();
+ }
findValuesStorageDescriptorsByPropertyId.setString(1, cid);
return findValuesStorageDescriptorsByPropertyId.executeQuery();
@@ -595,12 +657,12 @@
.prepareStatement("DELETE FROM JCR_SVALUE WHERE PROPERTY_ID "
+ "IN (SELECT ID FROM JCR_SITEM WHERE CONTAINER_NAME = ? AND
"
+ "(NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR
NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'))");
- removeValuesStatement.setString(1, containerName);
+ removeValuesStatement.setString(1, this.containerConfig.containerName);
removeItemsStatement =
dbConnection.prepareStatement("DELETE FROM JCR_SITEM WHERE
CONTAINER_NAME = ? AND "
+ "(NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR NAME =
'[http://www.jcp.org/jcr/1.0]lockOwner')");
- removeItemsStatement.setString(1, containerName);
+ removeItemsStatement.setString(1, this.containerConfig.containerName);
removeValuesStatement.executeUpdate();
removeItemsStatement.executeUpdate();
@@ -648,7 +710,7 @@
findNodesCount.clearParameters();
}
- findNodesCount.setString(1, containerName);
+ findNodesCount.setString(1, this.containerConfig.containerName);
return findNodesCount.executeQuery();
}
@@ -667,14 +729,14 @@
dbConnection.prepareStatement("DELETE FROM JCR_SVALUE WHERE PROPERTY_ID
IN (SELECT ID FROM JCR_SITEM"
+ " WHERE CONTAINER_NAME = ? AND PARENT_ID=? AND (NAME =
'[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'))");
- removeValuesStatement.setString(1, containerName);
+ removeValuesStatement.setString(1, containerConfig.containerName);
removeValuesStatement.setString(2, getInternalId(nodeIdentifier));
removeItemsStatement =
dbConnection.prepareStatement("DELETE FROM JCR_SITEM WHERE
CONTAINER_NAME = ? AND PARENT_ID=? AND"
+ " (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep'
OR"
+ " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
- removeItemsStatement.setString(1, containerName);
+ removeItemsStatement.setString(1, containerConfig.containerName);
removeItemsStatement.setString(2, getInternalId(nodeIdentifier));
removeValuesStatement.executeUpdate();
@@ -719,7 +781,7 @@
}
findMaxPropertyVersions.setString(1, getInternalId(parentId));
- findMaxPropertyVersions.setString(2, containerName);
+ findMaxPropertyVersions.setString(2, containerConfig.containerName);
findMaxPropertyVersions.setString(3, name);
findMaxPropertyVersions.setInt(4, index);
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/IngresSQLDBInitializer.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/IngresSQLDBInitializer.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/IngresSQLDBInitializer.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -18,6 +18,8 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.init;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
+
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -38,10 +40,9 @@
public class IngresSQLDBInitializer extends StorageDBInitializer
{
- public IngresSQLDBInitializer(String containerName, Connection connection, String
scriptPath, boolean multiDb)
- throws IOException
+ public IngresSQLDBInitializer(Connection connection, JDBCDataContainerConfig
containerConfig) throws IOException
{
- super(containerName, connection, scriptPath, multiDb);
+ super(connection, containerConfig);
}
/**
@@ -76,7 +77,9 @@
{
// check if sequence does not exist
if (e.getMessage().indexOf("DEFINE CURSOR") >= 0 &&
e.getMessage().indexOf("Sequence") >= 0)
+ {
return false;
+ }
throw new SQLException(e.getMessage())
{
/**
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/OracleDBInitializer.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/OracleDBInitializer.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/OracleDBInitializer.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -18,6 +18,8 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.init;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
+
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -38,10 +40,9 @@
public class OracleDBInitializer extends StorageDBInitializer
{
- public OracleDBInitializer(String containerName, Connection connection, String
scriptPath, boolean multiDb)
- throws IOException
+ public OracleDBInitializer(Connection connection, JDBCDataContainerConfig
containerConfig) throws IOException
{
- super(containerName, connection, scriptPath, multiDb);
+ super(connection, containerConfig);
}
@Override
@@ -63,7 +64,9 @@
{
// check: ORA-02289: sequence does not exist
if (e.getMessage().indexOf("ORA-02289") >= 0)
+ {
return false;
+ }
throw e;
}
finally
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/PgSQLDBInitializer.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/PgSQLDBInitializer.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/PgSQLDBInitializer.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -18,6 +18,8 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.init;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
+
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
@@ -36,10 +38,9 @@
public class PgSQLDBInitializer extends StorageDBInitializer
{
- public PgSQLDBInitializer(String containerName, Connection connection, String
scriptPath, boolean multiDb)
- throws IOException
+ public PgSQLDBInitializer(Connection connection, JDBCDataContainerConfig
containerConfig) throws IOException
{
- super(containerName, connection, scriptPath, multiDb);
+ super(connection, containerConfig);
}
@Override
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/StorageDBInitializer.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/StorageDBInitializer.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/StorageDBInitializer.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -19,6 +19,8 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.init;
import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
+import
org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig.DatabaseStructureType;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;
@@ -36,14 +38,27 @@
*/
public class StorageDBInitializer extends DBInitializer
{
+ public StorageDBInitializer(Connection connection, JDBCDataContainerConfig
containerConfig) throws IOException
+ {
+ super(connection, containerConfig);
+ }
- protected final boolean multiDb;
+ protected String prepareScripts() throws IOException
+ {
+ if (containerConfig.dbStructureType == DatabaseStructureType.ISOLATED)
+ {
+ // Replace the names of Database entities
+ String scripts = super.prepareScripts();
- public StorageDBInitializer(String containerName, Connection connection, String
scriptPath, boolean multiDb)
- throws IOException
- {
- super(containerName, connection, scriptPath);
- this.multiDb = multiDb;
+ return scripts.replace("MITEM", "I" +
containerConfig.dbTableSuffix)
+ .replace("MVALUE", "V" + containerConfig.dbTableSuffix)
+ .replace("MREF", "R" + containerConfig.dbTableSuffix);
+ }
+ else
+ {
+ return super.prepareScripts();
+ }
+
}
/**
@@ -52,14 +67,27 @@
@Override
protected void postInit(Connection connection) throws SQLException
{
- final String MDB = (multiDb ? "M" : "S");
+ String tableSuffix = "";
+ switch (containerConfig.dbStructureType)
+ {
+ case MULTI :
+ tableSuffix = "MITEM";
+ break;
+ case SINGLE :
+ tableSuffix = "SITEM";
+ break;
+ case ISOLATED :
+ tableSuffix = "I" + containerConfig.dbTableSuffix;
+ break;
+ }
String select =
- "select * from JCR_" + MDB + "ITEM where ID='" +
Constants.ROOT_PARENT_UUID + "' and PARENT_ID='"
+ "select * from JCR_" + tableSuffix + " where ID='" +
Constants.ROOT_PARENT_UUID + "' and PARENT_ID='"
+ Constants.ROOT_PARENT_UUID + "'";
if (!connection.createStatement().executeQuery(select).next())
{
- String insert = DBInitializerHelper.getRootNodeInitializeScript(multiDb);
+ // TODO
+ String insert =
DBInitializerHelper.getRootNodeInitializeScript(containerConfig);
connection.createStatement().executeUpdate(insert);
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -37,18 +37,16 @@
import org.exoplatform.services.jcr.impl.dataflow.persistent.ACLHolder;
import org.exoplatform.services.jcr.impl.dataflow.persistent.StreamPersistedValueData;
import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
import org.exoplatform.services.jcr.impl.storage.jdbc.PrimaryTypeNotFoundException;
import org.exoplatform.services.jcr.impl.storage.value.ValueStorageNotFoundException;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.impl.util.io.SwapFile;
import org.exoplatform.services.jcr.storage.value.ValueIOChannel;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import java.io.ByteArrayInputStream;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
@@ -56,16 +54,7 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
+import java.util.*;
import javax.jcr.InvalidItemStateException;
import javax.jcr.PropertyType;
@@ -163,30 +152,21 @@
protected Statement findNodesByParentIdAndComplexPatternCQ;
/**
- * JDBCStorageConnection constructor.
- *
- * @param dbConnection
- * JDBC connection
- * @param containerName
- * Workspace container name
- * @param valueStorageProvider
- * External Value Storage provider
- * @param maxBufferSize
- * maximum buffer size (configuration)
- * @param swapDirectory
- * swap directory (configuration)
- * @param swapCleaner
- * swap cleaner (FileCleaner)
- * @throws SQLException
- * database error
- */
- protected CQJDBCStorageConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ * JDBCStorageConnection constructor.
+ *
+ * @param dbConnection
+ * JDBC connection, should be opened before
+ * @param readOnly
+ * boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerConfig
+ * Workspace Storage Container configuration
+ */
+ protected CQJDBCStorageConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
-
+
/**
* {@inheritDoc}
*/
@@ -201,7 +181,7 @@
// query will return all the ACL holder
resultSet = findACLHolders();
Map<String, ACLHolder> mHolders = new HashMap<String, ACLHolder>();
-
+
while (resultSet.next())
{
String cpid = resultSet.getString(COLUMN_PARENTID);
@@ -242,7 +222,7 @@
}
}
}
- }
+ }
/**
* {@inheritDoc}
@@ -563,7 +543,7 @@
for (int i = 0; i < vdata.size(); i++)
{
ValueData vd = vdata.get(i);
- ValueIOChannel channel = valueStorageProvider.getApplicableChannel(data, i);
+ ValueIOChannel channel =
this.containerConfig.valueStorageProvider.getApplicableChannel(data, i);
InputStream stream;
int streamLength;
String storageId;
@@ -580,7 +560,8 @@
{
StreamPersistedValueData streamData = (StreamPersistedValueData)vd;
- SwapFile swapFile = SwapFile.get(swapDirectory, cid + i + "." +
data.getPersistedVersion());
+ SwapFile swapFile =
+ SwapFile.get(this.containerConfig.swapDirectory, cid + i +
"." + data.getPersistedVersion());
try
{
writeValueHelper.writeStreamedValue(swapFile, streamData);
@@ -630,7 +611,7 @@
{
for (String storageId : storageDescs)
{
- final ValueIOChannel channel = valueStorageProvider.getChannel(storageId);
+ final ValueIOChannel channel =
this.containerConfig.valueStorageProvider.getChannel(storageId);
try
{
channel.delete(pdata.getIdentifier());
@@ -685,8 +666,8 @@
try
{
qpath =
- QPath.makeChildPath(parentPath == null ? traverseQPath(cpid) :
parentPath, InternalQName
- .parse(cname));
+ QPath.makeChildPath(parentPath == null ? traverseQPath(cpid) :
parentPath,
+ InternalQName.parse(cname));
}
catch (IllegalNameException e)
{
@@ -703,8 +684,8 @@
{
final String storageId = resultSet.getString(COLUMN_VSTORAGE_DESC);
ValueData vdata =
- resultSet.wasNull() ? readValueData(cid, orderNum, cversion,
resultSet
- .getBinaryStream(COLUMN_VDATA)) : readValueData(identifier,
orderNum, storageId);
+ resultSet.wasNull() ? readValueData(cid, orderNum, cversion,
+ resultSet.getBinaryStream(COLUMN_VDATA)) :
readValueData(identifier, orderNum, storageId);
data.add(vdata);
}
@@ -786,8 +767,8 @@
try
{
qpath =
- QPath.makeChildPath(parentPath == null ? traverseQPath(cpid) :
parentPath, InternalQName
- .parse(cname));
+ QPath.makeChildPath(parentPath == null ? traverseQPath(cpid) :
parentPath,
+ InternalQName.parse(cname));
}
catch (IllegalNameException e)
{
@@ -804,8 +785,8 @@
{
final String storageId = resultSet.getString(COLUMN_VSTORAGE_DESC);
ValueData vdata =
- resultSet.wasNull() ? readValueData(cid, orderNum, cversion,
resultSet
- .getBinaryStream(COLUMN_VDATA)) : readValueData(identifier,
orderNum, storageId);
+ resultSet.wasNull() ? readValueData(cid, orderNum, cversion,
+ resultSet.getBinaryStream(COLUMN_VDATA)) :
readValueData(identifier, orderNum, storageId);
data.add(vdata);
}
@@ -1007,7 +988,7 @@
if (primaryType == null || primaryType.isEmpty())
{
throw new PrimaryTypeNotFoundException("FATAL ERROR primary type record
not found. Node "
- + qpath.getAsString() + ", id " + cid + ", container "
+ this.containerName, null);
+ + qpath.getAsString() + ", id " + cid + ", container "
+ this.containerConfig.containerName, null);
}
byte[] data = primaryType.first().getValueData().getAsByteArray();
@@ -1060,8 +1041,8 @@
{
// use permissions from existed parent
acl =
- new AccessControlList(readACLOwner(cid, properties),
parentACL.hasPermissions() ? parentACL
- .getPermissionEntries() : null);
+ new AccessControlList(readACLOwner(cid, properties),
parentACL.hasPermissions()
+ ? parentACL.getPermissionEntries() : null);
}
else
{
@@ -1095,8 +1076,8 @@
{
// construct ACL from existed parent ACL
acl =
- new AccessControlList(parentACL.getOwner(),
parentACL.hasPermissions() ? parentACL
- .getPermissionEntries() : null);
+ new AccessControlList(parentACL.getOwner(),
parentACL.hasPermissions()
+ ? parentACL.getPermissionEntries() : null);
}
else
{
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -80,6 +80,7 @@
{
super(wsConfig, repConfig, contextInit, valueStorageProvider, fileCleanerHolder,
dsProvider);
}
+
/**
* Init storage database.
*
@@ -95,177 +96,154 @@
{
StorageDBInitializer dbInitializer = null;
- String sqlPath = DBInitializerHelper.scriptPath(dbDialect, multiDb);
- if (dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
+ if (containerConfig.dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
{
LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is
experimental!");
// sample of connection factory customization
- if (dbSourceName != null)
+ if (containerConfig.dbSourceName != null)
{
- this.connFactory =
- new DefaultOracleConnectionFactory(getDataSource(), containerName,
multiDb, valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner, useQueryHints);
+ this.connFactory = new DefaultOracleConnectionFactory(getDataSource(),
containerConfig);
}
else
- this.connFactory =
- new OracleConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner,
useQueryHints);
+ {
+ this.connFactory = new OracleConnectionFactory(containerConfig);
+ }
// a particular db initializer may be configured here too
- dbInitializer = new OracleDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
+ dbInitializer =
+ new OracleDBInitializer(this.connFactory.getJdbcConnection(),
containerConfig);
}
- else if (dbDialect == DBConstants.DB_DIALECT_ORACLE)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_ORACLE)
{
- if (dbSourceName != null)
+ if (containerConfig.dbSourceName != null)
{
- this.connFactory =
- new DefaultOracleConnectionFactory(getDataSource(), containerName,
multiDb, valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner, useQueryHints);
+ this.connFactory = new DefaultOracleConnectionFactory(getDataSource(),
containerConfig);
}
else
- this.connFactory =
- new DefaultOracleConnectionFactory(dbDriver, dbUrl, dbUserName,
dbPassword, containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner,
useQueryHints);
- dbInitializer = new OracleDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
+ {
+ this.connFactory = new DefaultOracleConnectionFactory(containerConfig);
+ }
}
- else if (dbDialect == DBConstants.DB_DIALECT_PGSQL)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_PGSQL)
{
- if (dbSourceName != null)
+ if (containerConfig.dbSourceName != null)
{
- this.connFactory =
- new PostgreConnectionFactory(getDataSource(), containerName, multiDb,
valueStorageProvider,
- maxBufferSize, swapDirectory, swapCleaner);
+ this.connFactory = new PostgreConnectionFactory(getDataSource(),
containerConfig);
}
else
- this.connFactory =
- new PostgreConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ {
+ this.connFactory = new PostgreConnectionFactory(containerConfig);
+ }
- dbInitializer = new PgSQLDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
+ dbInitializer =
+ new PgSQLDBInitializer(this.connFactory.getJdbcConnection(),
containerConfig);
}
- else if (dbDialect == DBConstants.DB_DIALECT_MYSQL || dbDialect ==
DBConstants.DB_DIALECT_MYSQL_UTF8 ||
- dbDialect == DBConstants.DB_DIALECT_MYSQL_MYISAM || dbDialect ==
DBConstants.DB_DIALECT_MYSQL_MYISAM_UTF8)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_MYSQL
+ || containerConfig.dbDialect == DBConstants.DB_DIALECT_MYSQL_UTF8
+ || containerConfig.dbDialect == DBConstants.DB_DIALECT_MYSQL_MYISAM
+ || containerConfig.dbDialect == DBConstants.DB_DIALECT_MYSQL_MYISAM_UTF8)
{
- if (dbDialect == DBConstants.DB_DIALECT_MYSQL_MYISAM || dbDialect ==
DBConstants.DB_DIALECT_MYSQL_MYISAM_UTF8)
+ if (containerConfig.dbDialect == DBConstants.DB_DIALECT_MYSQL_MYISAM
+ || containerConfig.dbDialect == DBConstants.DB_DIALECT_MYSQL_MYISAM_UTF8)
{
LOG.warn("MyISAM is not supported due to its lack of transaction support
and integrity check, so use it only"
+ " if you don't expect any support and performances in read
accesses are more important than the consistency"
+ " in your use-case. This dialect is only dedicated to the
community.");
}
- if (dbSourceName != null)
+ if (containerConfig.dbSourceName != null)
{
- this.connFactory =
- new MySQLConnectionFactory(getDataSource(), containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ this.connFactory = new MySQLConnectionFactory(getDataSource(),
containerConfig);
}
else
- this.connFactory =
- new MySQLConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ {
+ this.connFactory = new MySQLConnectionFactory(containerConfig);
+ }
- dbInitializer = defaultDBInitializer(sqlPath);
+ dbInitializer = defaultDBInitializer();
}
- else if (dbDialect == DBConstants.DB_DIALECT_MSSQL)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_MSSQL)
{
- if (dbSourceName != null)
+ if (containerConfig.dbSourceName != null)
{
- this.connFactory =
- new MSSQLConnectionFactory(getDataSource(), containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ this.connFactory = new MSSQLConnectionFactory(getDataSource(),
containerConfig);
}
else
{
- this.connFactory =
- new MSSQLConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ this.connFactory = new MSSQLConnectionFactory(containerConfig);
}
- dbInitializer = defaultDBInitializer(sqlPath);
+ dbInitializer = defaultDBInitializer();
}
- else if (dbDialect == DBConstants.DB_DIALECT_DERBY)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_DERBY)
{
this.connFactory = defaultConnectionFactory();
- dbInitializer = defaultDBInitializer(sqlPath);
+ dbInitializer = defaultDBInitializer();
}
- else if (dbDialect == DBConstants.DB_DIALECT_DB2)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_DB2)
{
- if (dbSourceName != null)
+ if (containerConfig.dbSourceName != null)
{
- this.connFactory =
- new DB2ConnectionFactory(getDataSource(), containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ this.connFactory = new DB2ConnectionFactory(getDataSource(),
containerConfig);
}
else
{
- this.connFactory =
- new DB2ConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ this.connFactory = new DB2ConnectionFactory(containerConfig);
}
- dbInitializer = defaultDBInitializer(sqlPath);
+ dbInitializer = defaultDBInitializer();
}
- else if (dbDialect == DBConstants.DB_DIALECT_DB2V8)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_DB2V8)
{
- if (dbSourceName != null)
+ if (containerConfig.dbSourceName != null)
{
- this.connFactory =
- new DB2ConnectionFactory(getDataSource(), containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ this.connFactory = new DB2ConnectionFactory(getDataSource(),
containerConfig);
}
else
{
- this.connFactory =
- new DB2ConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ this.connFactory = new DB2ConnectionFactory(containerConfig);
}
- dbInitializer = defaultDBInitializer(sqlPath);
+ dbInitializer = defaultDBInitializer();
}
- else if (dbDialect == DBConstants.DB_DIALECT_SYBASE)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_SYBASE)
{
- if (dbSourceName != null)
+ if (containerConfig.dbSourceName != null)
{
- this.connFactory =
- new SybaseConnectionFactory(getDataSource(), containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ this.connFactory = new SybaseConnectionFactory(getDataSource(),
containerConfig);
}
else
{
- this.connFactory =
- new SybaseConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ this.connFactory = new SybaseConnectionFactory(containerConfig);
}
- dbInitializer = defaultDBInitializer(sqlPath);
+ dbInitializer = defaultDBInitializer();
}
- else if (dbDialect == DBConstants.DB_DIALECT_INGRES)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_INGRES)
{
this.connFactory = defaultConnectionFactory();
// using Postgres initializer
dbInitializer =
- new IngresSQLDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
+ new IngresSQLDBInitializer(this.connFactory.getJdbcConnection(),
containerConfig);
}
- else if (dbDialect == DBConstants.DB_DIALECT_HSQLDB)
+ else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_HSQLDB)
{
- if (dbSourceName != null)
+ if (containerConfig.dbSourceName != null)
{
- this.connFactory =
- new HSQLDBConnectionFactory(getDataSource(), containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ this.connFactory = new HSQLDBConnectionFactory(getDataSource(),
containerConfig);
}
else
- this.connFactory =
- new HSQLDBConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
- dbInitializer = defaultDBInitializer(sqlPath);
+ {
+ this.connFactory = new HSQLDBConnectionFactory(containerConfig);
+ }
+ dbInitializer = defaultDBInitializer();
}
else
{
// generic, DB_HSQLDB
this.connFactory = defaultConnectionFactory();
- dbInitializer = defaultDBInitializer(sqlPath);
+ dbInitializer = defaultDBInitializer();
}
// database type
@@ -292,13 +270,11 @@
protected GenericConnectionFactory defaultConnectionFactory() throws NamingException,
RepositoryException
{
// by default
- if (dbSourceName != null)
+ if (containerConfig.dbSourceName != null)
{
- return new GenericCQConnectionFactory(getDataSource(), containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ return new GenericCQConnectionFactory(getDataSource(), containerConfig);
}
- return new GenericCQConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
- }
+ return new GenericCQConnectionFactory(containerConfig);
+ }
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2ConnectionFactory.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2ConnectionFactory.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2ConnectionFactory.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
@@ -49,62 +50,18 @@
/**
* DB2ConnectionFactory constructor.
- *
- * @param dataSource
- * - DataSource
- * @param dbDriver
- * - JDBC Driver
- * @param dbUrl
- * - JDBC URL
- * @param dbUserName
- * - database username
- * @param dbPassword
- * - database user password
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- * @throws RepositoryException
- * if error eccurs
*/
- public DB2ConnectionFactory(String dbDriver, String dbUrl, String dbUserName, String
dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ public DB2ConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
{
- super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ super(containerConfig);
}
/**
* DB2ConnectionFactory constructor.
- *
- * @param dataSource
- * - DataSource
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
*/
- public DB2ConnectionFactory(DataSource dbDataSource, String containerName, boolean
multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public DB2ConnectionFactory(DataSource dataSource, JDBCDataContainerConfig
containerConfig)
{
- super(dbDataSource, containerName, multiDb, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dataSource, containerConfig);
}
/**
@@ -115,14 +72,12 @@
{
try
{
- if (multiDb)
+ if (this.containerConfig.dbStructureType.isSimpleTable())
{
- return new DB2MultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new DB2MultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
- return new DB2SingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new DB2SingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
catch (SQLException e)
@@ -130,7 +85,7 @@
throw new RepositoryException(e);
}
}
-
+
/**
* {@inheritDoc}
*/
@@ -139,7 +94,7 @@
{
return true;
}
-
+
/**
* {@inheritDoc}
*/
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2MultiDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2MultiDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2MultiDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -16,10 +16,8 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -38,28 +36,16 @@
* DB2 Multidatabase JDBC Connection constructor.
*
* @param dbConnection
- * JDBC connection, shoudl be opened before
+ * JDBC connection, should be opened before
* @param readOnly
* boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName
- * Workspace Storage Container name (see configuration)
- * @param valueStorageProvider
- * External Value Storages provider
- * @param maxBufferSize
- * Maximum buffer size (see configuration)
- * @param swapDirectory
- * Swap directory File (see configuration)
- * @param swapCleaner
- * Swap cleaner (internal FileCleaner).
- * @throws SQLException
- *
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ * @param containerConfig
+ * Workspace Storage Container configuration
*/
- public DB2MultiDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public DB2MultiDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -71,12 +57,12 @@
super.prepareQueries();
FIND_NODES_AND_PROPERTIES =
"select J.*, P.ID AS P_ID, P.NAME AS P_NAME, P.VERSION AS P_VERSION,
P.P_TYPE, P.P_MULTIVALUED,"
- + " V.DATA, V.ORDER_NUM, V.STORAGE_DESC from JCR_MVALUE V, JCR_MITEM
P"
- + " join (select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_INDEX,
I.N_ORDER_NUM from JCR_MITEM I"
+ + " V.DATA, V.ORDER_NUM, V.STORAGE_DESC from " + JCR_VALUE + "
V, " + JCR_ITEM + " P"
+ + " join (select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_INDEX,
I.N_ORDER_NUM from " + JCR_ITEM + " I"
+ " where I.I_CLASS=1 AND I.ID > ? order by I.ID LIMIT ?,?) J on
P.PARENT_ID = J.ID"
+ " where P.I_CLASS=2 and V.PROPERTY_ID=P.ID order by J.ID";
}
-
+
/**
* {@inheritDoc}
*/
@@ -97,5 +83,5 @@
findNodesAndProperties.setInt(3, limit);
return findNodesAndProperties.executeQuery();
- }
+ }
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2SingleDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2SingleDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2SingleDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -16,10 +16,8 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -41,25 +39,13 @@
* JDBC connection, should be opened before
* @param readOnly
* boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName
- * Workspace Storage Container name (see configuration)
- * @param valueStorageProvider
- * External Value Storages provider
- * @param maxBufferSize
- * Maximum buffer size (see configuration)
- * @param swapDirectory
- * Swap directory File (see configuration)
- * @param swapCleaner
- * Swap cleaner (internal FileCleaner).
- * @throws SQLException
- *
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ * @param containerConfig
+ * Workspace Storage Container configuration
*/
- public DB2SingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public DB2SingleDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -92,11 +78,11 @@
findNodesAndProperties.clearParameters();
}
- findNodesAndProperties.setString(1, containerName);
+ findNodesAndProperties.setString(1, this.containerConfig.containerName);
findNodesAndProperties.setString(2, getInternalId(lastNodeId));
findNodesAndProperties.setInt(3, offset);
findNodesAndProperties.setInt(4, limit);
- findNodesAndProperties.setString(5, containerName);
+ findNodesAndProperties.setString(5, this.containerConfig.containerName);
return findNodesAndProperties.executeQuery();
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -16,11 +16,9 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import java.io.File;
import java.sql.SQLException;
import javax.jcr.RepositoryException;
@@ -34,75 +32,21 @@
*/
public class DefaultOracleConnectionFactory extends GenericCQConnectionFactory
{
-
- protected boolean forceQueryHints;
-
/**
* DefaultOracleConnectionFactory constructor.
- *
- * @param dataSource
- * - DataSource
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- * @param forceQueryHints
- * - use Oracle queries with query hints
*/
- public DefaultOracleConnectionFactory(DataSource dataSource, String containerName,
boolean multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner,
- boolean forceQueryHints)
+ public DefaultOracleConnectionFactory(DataSource dataSource, JDBCDataContainerConfig
containerConfig)
{
- super(dataSource, containerName, multiDb, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
- this.forceQueryHints = forceQueryHints;
+ super(dataSource, containerConfig);
}
/**
* DefaultOracleConnectionFactory constructor.
- *
- *@param dataSource
- * - DataSource
- * @param dbDriver
- * - JDBC Driver
- * @param dbUrl
- * - JDBC URL
- * @param dbUserName
- * - database username
- * @param dbPassword
- * - database user password
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- * @param forceQueryHints
- * - use Oracle queries with query hints
- * @throws RepositoryException
- * if error eccurs
*/
- public DefaultOracleConnectionFactory(String dbDriver, String dbUrl, String
dbUserName, String dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner, boolean forceQueryHints) throws
RepositoryException
+ public DefaultOracleConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
{
- super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
- this.forceQueryHints = forceQueryHints;
+ super(containerConfig);
}
/**
@@ -113,16 +57,16 @@
{
try
{
- if (forceQueryHints)
+ if (containerConfig.useQueryHints)
{
- if (multiDb)
+ if (this.containerConfig.dbStructureType.isSimpleTable())
{
- return new OracleMultiDbJDBCConnection(getJdbcConnection(readOnly),
readOnly, containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new OracleMultiDbJDBCConnection(getJdbcConnection(readOnly),
readOnly,
+ containerConfig);
}
- return new OracleSingleDbJDBCConnection(getJdbcConnection(readOnly),
readOnly, containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new OracleSingleDbJDBCConnection(getJdbcConnection(readOnly),
readOnly,
+ containerConfig);
}
else
{
@@ -136,7 +80,7 @@
throw new RepositoryException(e);
}
}
-
+
/**
* {@inheritDoc}
*/
@@ -144,5 +88,5 @@
public boolean isIDNeededForPaging()
{
return false;
- }
+ }
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/GenericCQConnectionFactory.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/GenericCQConnectionFactory.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/GenericCQConnectionFactory.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -19,12 +19,10 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
import org.exoplatform.commons.utils.ClassLoading;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.GenericConnectionFactory;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
@@ -45,99 +43,23 @@
/**
* GenericConnectionFactory constructor.
- *
- * @param dataSource
- * - DataSource
- * @param dbDriver
- * - JDBC Driver
- * @param dbUrl
- * - JDBC URL
- * @param dbUserName
- * - database username
- * @param dbPassword
- * - database user password
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
*/
- protected GenericCQConnectionFactory(DataSource dataSource, String dbDriver, String
dbUrl, String dbUserName,
- String dbPassword, String containerName, boolean multiDb,
ValueStoragePluginProvider valueStorageProvider,
- int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
+ public GenericCQConnectionFactory(DataSource dataSource, JDBCDataContainerConfig
containerConfig)
{
- super(dataSource, dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider,
- maxBufferSize, swapDirectory, swapCleaner);
+ super(dataSource, containerConfig);
}
/**
* GenericConnectionFactory constructor.
- *
- * @param dataSource
- * - DataSource
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
*/
- public GenericCQConnectionFactory(DataSource dataSource, String containerName, boolean
multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public GenericCQConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
{
- this(dataSource, null, null, null, null, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
- }
+ this(null, containerConfig);
- /**
- * GenericConnectionFactory constructor.
- *
- * @param dbDriver
- * - JDBC Driver
- * @param dbUrl
- * - JDBC URL
- * @param dbUserName
- * - database username
- * @param dbPassword
- * - database user password
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- */
- public GenericCQConnectionFactory(String dbDriver, String dbUrl, String dbUserName,
String dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
- {
-
- this(null, dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
-
try
{
- ClassLoading.forName(dbDriver, this).newInstance();
+ ClassLoading.forName(this.containerConfig.dbDriver, this).newInstance();
}
catch (InstantiationException e)
{
@@ -171,14 +93,12 @@
try
{
- if (multiDb)
+ if (this.containerConfig.dbStructureType.isSimpleTable())
{
- return new MultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new MultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
- return new SingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName, valueStorageProvider,
- maxBufferSize, swapDirectory, swapCleaner);
+ return new SingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
catch (SQLException e)
@@ -195,8 +115,10 @@
{
try
{
- Connection conn = dbDataSource != null ? dbDataSource.getConnection() :
(dbUserName != null ? DriverManager
- .getConnection(dbUrl, dbUserName, dbPassword) :
DriverManager.getConnection(dbUrl));
+ Connection conn =
+ dbDataSource != null ? dbDataSource.getConnection() :
(this.containerConfig.dbUserName != null
+ ? DriverManager.getConnection(this.containerConfig.dbUrl,
this.containerConfig.dbUserName,
+ this.containerConfig.dbPassword) :
DriverManager.getConnection(this.containerConfig.dbUrl));
return conn;
}
@@ -217,7 +139,7 @@
{
return getJdbcConnection(false);
}
-
+
/**
* {@inheritDoc}
*/
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBConnectionFactory.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBConnectionFactory.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBConnectionFactory.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -16,11 +16,9 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import java.io.File;
import java.sql.SQLException;
import javax.jcr.RepositoryException;
@@ -39,64 +37,20 @@
/**
* HSQLDBConnectionFactory constructor.
- *
- * @param dataSource
- * - DataSource
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
*/
- public HSQLDBConnectionFactory(DataSource dataSource, String containerName, boolean
multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public HSQLDBConnectionFactory(DataSource dataSource, JDBCDataContainerConfig
containerConfig)
{
- super(dataSource, containerName, multiDb, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dataSource, containerConfig);
}
/**
* HSQLDBConnectionFactory constructor.
- *
- *@param dataSource
- * - DataSource
- * @param dbDriver
- * - JDBC Driver
- * @param dbUrl
- * - JDBC URL
- * @param dbUserName
- * - database username
- * @param dbPassword
- * - database user password
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- * @throws RepositoryException
- * if error eccurs
*/
- public HSQLDBConnectionFactory(String dbDriver, String dbUrl, String dbUserName,
String dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ public HSQLDBConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
{
- super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ super(containerConfig);
}
/**
@@ -107,14 +61,13 @@
try
{
- if (multiDb)
+ if (this.containerConfig.dbStructureType.isSimpleTable())
{
- return new HSQLDBMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new HSQLDBMultiDbJDBCConnection(getJdbcConnection(readOnly),
readOnly,
+ containerConfig);
}
- return new HSQLDBSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new HSQLDBSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
catch (SQLException e)
@@ -122,7 +75,7 @@
throw new RepositoryException(e);
}
}
-
+
/**
* {@inheritDoc}
*/
@@ -130,5 +83,5 @@
public boolean isReindexingSupport()
{
return false;
- }
+ }
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -19,10 +19,8 @@
import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.impl.core.itemfilters.QPathEntryFilter;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -44,28 +42,16 @@
* HSQLDB Multidatabase JDBC Connection constructor.
*
* @param dbConnection
- * JDBC connection, shoudl be opened before
+ * JDBC connection, should be opened before
* @param readOnly
* boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName
- * Workspace Storage Container name (see configuration)
- * @param valueStorageProvider
- * External Value Storages provider
- * @param maxBufferSize
- * Maximum buffer size (see configuration)
- * @param swapDirectory
- * Swap directory File (see configuration)
- * @param swapCleaner
- * Swap cleaner (internal FileCleaner).
- * @throws SQLException
- *
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ * @param containerConfig
+ * Workspace Storage Container configuration
*/
- public HSQLDBMultiDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public HSQLDBMultiDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -76,18 +62,19 @@
{
super.prepareQueries();
FIND_PROPERTY_BY_NAME =
- "select V.DATA" + " from JCR_MITEM I, JCR_MVALUE V"
+ "select V.DATA" + " from " + JCR_ITEM + " I, " +
JCR_VALUE + " V"
+ " where I.PARENT_ID=? and I.I_CLASS=2 and I.NAME=? and
I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
- FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where
PARENT_ID=? and I_CLASS=1" + " order by N_ORDER_NUM";
+ FIND_NODES_BY_PARENTID =
+ "select * from " + JCR_ITEM + " where PARENT_ID=? and
I_CLASS=1" + " order by N_ORDER_NUM";
FIND_LAST_ORDER_NUMBER_BY_PARENTID =
- "select count(*), max(N_ORDER_NUM) from JCR_MITEM where PARENT_ID=? and
I_CLASS=1";
+ "select count(*), max(N_ORDER_NUM) from " + JCR_ITEM + " where
PARENT_ID=? and I_CLASS=1";
- FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + "
where PARENT_ID=? and I_CLASS=1";
- FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where
PARENT_ID=? and I_CLASS=2" + " order by ID";
+ FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from " + JCR_ITEM +
" where PARENT_ID=? and I_CLASS=1";
+ FIND_PROPERTIES_BY_PARENTID = "select * from " + JCR_ITEM + " where
PARENT_ID=? and I_CLASS=2" + " order by ID";
FIND_NODES_BY_PARENTID_CQ =
- "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA from JCR_MITEM I,
JCR_MITEM P, JCR_MVALUE V"
- + " where I.PARENT_ID=? and I.I_CLASS=1 and (P.PARENT_ID=I.ID and
P.I_CLASS=2 and"
+ "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA from " +
JCR_ITEM + " I, " + JCR_ITEM + " P, "
+ + JCR_VALUE + " V" + " where I.PARENT_ID=? and I.I_CLASS=1 and
(P.PARENT_ID=I.ID and P.I_CLASS=2 and"
+ " (
P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or"
+ "
P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or"
+ "
P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'
or"
@@ -95,9 +82,10 @@
+ " order by I.N_ORDER_NUM, I.ID";
FIND_PROPERTIES_BY_PARENTID_CQ =
"select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX,
I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED,"
- + " V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT OUTER JOIN
JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)"
- + " where I.PARENT_ID=? and I.I_CLASS=2 order by I.NAME";
+ + " V.ORDER_NUM, V.DATA, V.STORAGE_DESC from " + JCR_ITEM + "
I LEFT OUTER JOIN " + JCR_VALUE
+ + " V ON (V.PROPERTY_ID=I.ID)" + " where I.PARENT_ID=? and
I.I_CLASS=2 order by I.NAME";
}
+
/**
* Use simple queries since it is much faster
*/
@@ -159,7 +147,7 @@
throw new SQLException("Pattern list is empty.");
}
else
- {
+ {
if (findPropertiesByParentIdAndComplexPatternCQ == null)
{
findPropertiesByParentIdAndComplexPatternCQ =
dbConnection.createStatement();
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -19,10 +19,8 @@
import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.impl.core.itemfilters.QPathEntryFilter;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -42,31 +40,19 @@
{
/**
- * HSQLDB Singledatabase JDBC Connection constructor.
- *
- * @param dbConnection
- * JDBC connection, should be opened before
- * @param readOnly
- * boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName
- * Workspace Storage Container name (see configuration)
- * @param valueStorageProvider
- * External Value Storages provider
- * @param maxBufferSize
- * Maximum buffer size (see configuration)
- * @param swapDirectory
- * Swap directory File (see configuration)
- * @param swapCleaner
- * Swap cleaner (internal FileCleaner).
- * @throws SQLException
- *
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
- */
- public HSQLDBSingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ * HSQLDB Singledatabase JDBC Connection constructor.
+ *
+ * @param dbConnection
+ * JDBC connection, should be opened before
+ * @param readOnly
+ * boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerConfig
+ * Workspace Storage Container configuration
+ */
+ public HSQLDBSingleDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -127,12 +113,16 @@
protected ResultSet findItemByName(String parentId, String name, int index) throws
SQLException
{
if (findItemByName == null)
+ {
findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
+ }
else
+ {
findItemByName.clearParameters();
+ }
findItemByName.setString(1, parentId);
- findItemByName.setString(2, containerName);
+ findItemByName.setString(2, this.containerConfig.containerName);
findItemByName.setString(3, name);
findItemByName.setInt(4, index);
@@ -146,12 +136,16 @@
protected ResultSet findPropertyByName(String parentCid, String name) throws
SQLException
{
if (findPropertyByName == null)
+ {
findPropertyByName = dbConnection.prepareStatement(FIND_PROPERTY_BY_NAME);
+ }
else
+ {
findPropertyByName.clearParameters();
+ }
findPropertyByName.setString(1, parentCid);
- findPropertyByName.setString(2, containerName);
+ findPropertyByName.setString(2, this.containerConfig.containerName);
findPropertyByName.setString(3, name);
return findPropertyByName.executeQuery();
@@ -164,12 +158,16 @@
protected ResultSet findChildNodesByParentIdentifier(String parentCid) throws
SQLException
{
if (findNodesByParentId == null)
+ {
findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
+ }
else
+ {
findNodesByParentId.clearParameters();
+ }
findNodesByParentId.setString(1, parentCid);
- findNodesByParentId.setString(2, containerName);
+ findNodesByParentId.setString(2, this.containerConfig.containerName);
return findNodesByParentId.executeQuery();
}
@@ -181,12 +179,16 @@
protected ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier)
throws SQLException
{
if (findLastOrderNumberByParentId == null)
+ {
findLastOrderNumberByParentId =
dbConnection.prepareStatement(FIND_LAST_ORDER_NUMBER_BY_PARENTID);
+ }
else
+ {
findLastOrderNumberByParentId.clearParameters();
+ }
findLastOrderNumberByParentId.setString(1, parentIdentifier);
- findLastOrderNumberByParentId.setString(2, containerName);
+ findLastOrderNumberByParentId.setString(2, this.containerConfig.containerName);
return findLastOrderNumberByParentId.executeQuery();
}
@@ -198,12 +200,16 @@
protected ResultSet findChildNodesCountByParentIdentifier(String parentCid) throws
SQLException
{
if (findNodesCountByParentId == null)
+ {
findNodesCountByParentId =
dbConnection.prepareStatement(FIND_NODES_COUNT_BY_PARENTID);
+ }
else
+ {
findNodesCountByParentId.clearParameters();
+ }
findNodesCountByParentId.setString(1, parentCid);
- findNodesCountByParentId.setString(2, containerName);
+ findNodesCountByParentId.setString(2, this.containerConfig.containerName);
return findNodesCountByParentId.executeQuery();
}
@@ -215,12 +221,16 @@
protected ResultSet findChildPropertiesByParentIdentifier(String parentCid) throws
SQLException
{
if (findPropertiesByParentId == null)
+ {
findPropertiesByParentId =
dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
+ }
else
+ {
findPropertiesByParentId.clearParameters();
+ }
findPropertiesByParentId.setString(1, parentCid);
- findPropertiesByParentId.setString(2, containerName);
+ findPropertiesByParentId.setString(2, this.containerConfig.containerName);
return findPropertiesByParentId.executeQuery();
}
@@ -232,13 +242,17 @@
protected ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier) throws
SQLException
{
if (findNodesByParentIdCQ == null)
+ {
findNodesByParentIdCQ =
dbConnection.prepareStatement(FIND_NODES_BY_PARENTID_CQ);
+ }
else
+ {
findNodesByParentIdCQ.clearParameters();
+ }
findNodesByParentIdCQ.setString(1, parentIdentifier);
- findNodesByParentIdCQ.setString(2, containerName);
- findNodesByParentIdCQ.setString(3, containerName);
+ findNodesByParentIdCQ.setString(2, this.containerConfig.containerName);
+ findNodesByParentIdCQ.setString(3, this.containerConfig.containerName);
return findNodesByParentIdCQ.executeQuery();
}
@@ -266,7 +280,7 @@
query.append(" where I.PARENT_ID='");
query.append(parentIdentifier);
query.append("' and I.I_CLASS=1 and I.CONTAINER_NAME='");
- query.append(containerName);
+ query.append(this.containerConfig.containerName);
query.append("' and ( ");
appendPattern(query, pattern.get(0).getQPathEntry(), true);
for (int i = 1; i < pattern.size(); i++)
@@ -275,7 +289,7 @@
appendPattern(query, pattern.get(i).getQPathEntry(), true);
}
query.append(" ) and P.PARENT_ID=I.ID and P.I_CLASS=2 and
P.CONTAINER_NAME='");
- query.append(containerName);
+ query.append(this.containerConfig.containerName);
query.append("' and
(
P.NAME='[http://www.jcp.org/jcr/1.0]primaryType'");
query.append(" or
P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes'");
query.append(" or
P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'");
@@ -293,12 +307,16 @@
protected ResultSet findChildPropertiesByParentIdentifierCQ(String parentIdentifier)
throws SQLException
{
if (findPropertiesByParentIdCQ == null)
+ {
findPropertiesByParentIdCQ =
dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID_CQ);
+ }
else
+ {
findPropertiesByParentIdCQ.clearParameters();
+ }
findPropertiesByParentIdCQ.setString(1, parentIdentifier);
- findPropertiesByParentIdCQ.setString(2, containerName);
+ findPropertiesByParentIdCQ.setString(2, this.containerConfig.containerName);
return findPropertiesByParentIdCQ.executeQuery();
}
@@ -326,7 +344,7 @@
query.append(" where I.PARENT_ID='");
query.append(parentCid);
query.append("' and I.I_CLASS=2 and I.CONTAINER_NAME='");
- query.append(containerName);
+ query.append(this.containerConfig.containerName);
query.append("' and ( ");
appendPattern(query, pattern.get(0).getQPathEntry(), false);
for (int i = 1; i < pattern.size(); i++)
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MSSQLConnectionFactory.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MSSQLConnectionFactory.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MSSQLConnectionFactory.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -18,11 +18,9 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import java.io.File;
import java.sql.SQLException;
import javax.jcr.RepositoryException;
@@ -41,62 +39,18 @@
/**
* MSSQLConnectionFactory constructor.
- *
- * @param dataSource
- * - DataSource
- * @param dbDriver
- * - JDBC Driver
- * @param dbUrl
- * - JDBC URL
- * @param dbUserName
- * - database username
- * @param dbPassword
- * - database user password
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- * @throws RepositoryException
- * if error eccurs
*/
- public MSSQLConnectionFactory(String dbDriver, String dbUrl, String dbUserName, String
dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ public MSSQLConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
{
- super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ super(containerConfig);
}
/**
* MSSQLConnectionFactory constructor.
- *
- * @param dataSource
- * - DataSource
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
*/
- public MSSQLConnectionFactory(DataSource dbDataSource, String containerName, boolean
multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public MSSQLConnectionFactory(DataSource dbDataSource, JDBCDataContainerConfig
containerConfig)
{
- super(dbDataSource, containerName, multiDb, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbDataSource, containerConfig);
}
/**
@@ -107,14 +61,12 @@
{
try
{
- if (multiDb)
+ if (this.containerConfig.dbStructureType.isSimpleTable())
{
- return new MSSQLMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new MSSQLMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
- return new MSSQLSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new MSSQLSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
catch (SQLException e)
@@ -122,7 +74,7 @@
throw new RepositoryException(e);
}
}
-
+
/**
* {@inheritDoc}
*/
@@ -130,5 +82,5 @@
public boolean isIDNeededForPaging()
{
return true;
- }
+ }
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MSSQLMultiDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MSSQLMultiDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MSSQLMultiDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -16,10 +16,8 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -36,12 +34,7 @@
* Template for query. Since there is no way to set parameter for TOP via prepared
statement.
* We need to replace it in the code.
*/
- public static final String FIND_NODES_AND_PROPERTIES_TEMPLATE =
- "select J.*, P.ID AS P_ID, P.NAME AS P_NAME, P.VERSION AS P_VERSION, P.P_TYPE,
P.P_MULTIVALUED,"
- + " V.DATA, V.ORDER_NUM, V.STORAGE_DESC from JCR_MVALUE V WITH (INDEX
(JCR_IDX_MVALUE_PROPERTY)), JCR_MITEM P"
- + " join (select TOP ${TOP} I.ID, I.PARENT_ID, I.NAME, I.VERSION,
I.I_INDEX, I.N_ORDER_NUM from JCR_MITEM I"
- + " WITH (INDEX (JCR_PK_MITEM)) where I.I_CLASS=1 AND I.ID > ? order by
I.ID) J on P.PARENT_ID = J.ID"
- + " where P.I_CLASS=2 and V.PROPERTY_ID=P.ID order by J.ID";
+ public String FIND_NODES_AND_PROPERTIES_TEMPLATE;
/**
* MSSQL Multidatabase JDBC Connection constructor.
@@ -50,25 +43,13 @@
* JDBC connection, should be opened before
* @param readOnly
* boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName
- * Workspace Storage Container name (see configuration)
- * @param valueStorageProvider
- * External Value Storages provider
- * @param maxBufferSize
- * Maximum buffer size (see configuration)
- * @param swapDirectory
- * Swap directory File (see configuration)
- * @param swapCleaner
- * Swap cleaner (internal FileCleaner).
- * @throws SQLException
- *
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ * @param containerConfig
+ * Workspace Storage Container configuration
*/
- public MSSQLMultiDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public MSSQLMultiDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -78,6 +59,14 @@
protected void prepareQueries() throws SQLException
{
super.prepareQueries();
+ FIND_NODES_AND_PROPERTIES_TEMPLATE =
+ "select J.*, P.ID AS P_ID, P.NAME AS P_NAME, P.VERSION AS P_VERSION,
P.P_TYPE, P.P_MULTIVALUED,"
+ + " V.DATA, V.ORDER_NUM, V.STORAGE_DESC from " + JCR_VALUE + "
V WITH (INDEX (" + JCR_IDX_VALUE_PROPERTY
+ + ")), " + JCR_ITEM + " P"
+ + " join (select TOP ${TOP} I.ID, I.PARENT_ID, I.NAME, I.VERSION,
I.I_INDEX, I.N_ORDER_NUM from "
+ + JCR_ITEM + " I" + " WITH (INDEX (" + JCR_PK_ITEM
+ + ")) where I.I_CLASS=1 AND I.ID > ? order by I.ID) J on P.PARENT_ID
= J.ID"
+ + " where P.I_CLASS=2 and V.PROPERTY_ID=P.ID order by J.ID";
}
/**
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MSSQLSingleDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MSSQLSingleDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MSSQLSingleDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -16,10 +16,8 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -53,25 +51,13 @@
* JDBC connection, should be opened before
* @param readOnly
* boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName
- * Workspace Storage Container name (see configuration)
- * @param valueStorageProvider
- * External Value Storages provider
- * @param maxBufferSize
- * Maximum buffer size (see configuration)
- * @param swapDirectory
- * Swap directory File (see configuration)
- * @param swapCleaner
- * Swap cleaner (internal FileCleaner).
- * @throws SQLException
- *
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ * @param containerConfig
+ * Workspace Storage Container configuration
*/
- public MSSQLSingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public MSSQLSingleDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -89,9 +75,9 @@
dbConnection.prepareStatement(FIND_NODES_AND_PROPERTIES_TEMPLATE.replace("${TOP}",
new Integer(offset + limit).toString()));
- findNodesAndProperties.setString(1, containerName);
+ findNodesAndProperties.setString(1, this.containerConfig.containerName);
findNodesAndProperties.setString(2, getInternalId(lastNodeId));
- findNodesAndProperties.setString(3, containerName);
+ findNodesAndProperties.setString(3, this.containerConfig.containerName);
return findNodesAndProperties.executeQuery();
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -25,11 +25,9 @@
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.itemfilters.QPathEntryFilter;
import org.exoplatform.services.jcr.impl.dataflow.ValueDataConvertor;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCStorageConnection;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
@@ -52,47 +50,28 @@
public class MultiDbJDBCConnection extends CQJDBCStorageConnection
{
+ protected String FIND_NODES_BY_PARENTID_CQ_QUERY;
- protected static final String FIND_NODES_BY_PARENTID_CQ_QUERY =
- "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA from JCR_MITEM I,
JCR_MITEM P, JCR_MVALUE V"
- + " where I.I_CLASS=1 and I.PARENT_ID=? and P.I_CLASS=2 and
P.PARENT_ID=I.ID and"
- + " (
P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or
P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes'"
- + " or
P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'"
- + " or
P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')"
- + " and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID";
+ protected String FIND_PROPERTIES_BY_PARENTID_CQ_QUERY;
- protected static final String FIND_PROPERTIES_BY_PARENTID_CQ_QUERY =
- "select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX,
I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED,"
- + " V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT OUTER JOIN
JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)"
- + " where I.I_CLASS=2 and I.PARENT_ID=? order by I.NAME";
-
- protected static final String FIND_ITEM_QPATH_BY_ID_CQ_QUERY =
- "select I.ID, I.PARENT_ID, I.NAME, I.I_INDEX"
- + " from JCR_MITEM I, (SELECT ID, PARENT_ID from JCR_MITEM where ID=?)
J"
- + " where I.ID = J.ID or I.ID = J.PARENT_ID";
+ protected String FIND_ITEM_QPATH_BY_ID_CQ_QUERY;
-
protected String PATTERN_ESCAPE_STRING = "\\"; //valid for HSQL, Sybase,
DB2, MSSQL, ORACLE
/**
* Multidatabase JDBC Connection constructor.
*
- * @param dbConnection JDBC connection, shoudl be opened before
- * @param readOnly, boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName Workspace Storage Container name (see configuration)
- * @param valueStorageProvider External Value Storages provider
- * @param maxBufferSize Maximum buffer size (see configuration)
- * @param swapDirectory Swap directory (see configuration)
- * @param swapCleaner Swap cleaner (internal FileCleaner).
- * @throws SQLException
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ * @param dbConnection
+ * JDBC connection, should be opened before
+ * @param readOnly
+ * boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerConfig
+ * Workspace Storage Container configuration
*/
- public MultiDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public MultiDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
-
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -119,43 +98,55 @@
@Override
protected void prepareQueries() throws SQLException
{
- JCR_PK_ITEM = "JCR_PK_MITEM";
- JCR_FK_ITEM_PARENT = "JCR_FK_MITEM_PARENT";
- JCR_IDX_ITEM_PARENT = "JCR_IDX_MITEM_PARENT";
- JCR_IDX_ITEM_PARENT_ID = "JCR_IDX_MITEM_PARENT_ID";
- JCR_PK_VALUE = "JCR_PK_MVALUE";
- JCR_FK_VALUE_PROPERTY = "JCR_FK_MVALUE_PROPERTY";
- JCR_IDX_VALUE_PROPERTY = "JCR_IDX_MVALUE_PROPERTY";
- JCR_PK_REF = "JCR_PK_MREF";
- JCR_IDX_REF_PROPERTY = "JCR_IDX_MREF_PROPERTY";
+ // ============================================================================
+ FIND_NODES_BY_PARENTID_CQ_QUERY =
+ "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA from " +
JCR_ITEM + " I, " + JCR_ITEM + " P, "
+ + JCR_VALUE + " V" + " where I.I_CLASS=1 and I.PARENT_ID=? and
P.I_CLASS=2 and P.PARENT_ID=I.ID and"
+ + " (
P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or
P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes'"
+ + " or
P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'"
+ + " or
P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')"
+ + " and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID";
- FIND_ITEM_BY_ID = "select * from JCR_MITEM where ID=?";
+ FIND_PROPERTIES_BY_PARENTID_CQ_QUERY =
+ "select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX,
I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED,"
+ + " V.ORDER_NUM, V.DATA, V.STORAGE_DESC from " + JCR_ITEM + "
I LEFT OUTER JOIN " + JCR_VALUE
+ + " V ON (V.PROPERTY_ID=I.ID)" + " where I.I_CLASS=2 and
I.PARENT_ID=? order by I.NAME";
+ FIND_ITEM_QPATH_BY_ID_CQ_QUERY =
+ "select I.ID, I.PARENT_ID, I.NAME, I.I_INDEX" + " from " +
JCR_ITEM + " I, (SELECT ID, PARENT_ID from "
+ + JCR_ITEM + " where ID=?) J" + " where I.ID = J.ID or I.ID =
J.PARENT_ID";
+ // ============================================================================
+
+ FIND_ITEM_BY_ID = "select * from " + JCR_ITEM + " where ID=?";
+
FIND_ITEM_BY_NAME =
- "select * from JCR_MITEM" + " where PARENT_ID=? and NAME=? and
I_INDEX=? order by I_CLASS, VERSION DESC";
+ "select * from " + JCR_ITEM + " where PARENT_ID=? and NAME=? and
I_INDEX=? order by I_CLASS, VERSION DESC";
FIND_PROPERTY_BY_NAME =
- "select V.DATA" + " from JCR_MITEM I, JCR_MVALUE V"
+ "select V.DATA" + " from " + JCR_ITEM + " I, " +
JCR_VALUE + " V"
+ " where I.I_CLASS=2 and I.PARENT_ID=? and I.NAME=? and
I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
FIND_REFERENCES =
- "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED,
P.NAME" + " from JCR_MREF R, JCR_MITEM P"
- + " where R.NODE_ID=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2";
+ "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED,
P.NAME" + " from " + JCR_REF + " R, "
+ + JCR_ITEM + " P" + " where R.NODE_ID=? and P.ID=R.PROPERTY_ID
and P.I_CLASS=2";
FIND_VALUES_BY_PROPERTYID =
- "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_MVALUE where
PROPERTY_ID=? order by ORDER_NUM";
+ "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from " + JCR_VALUE
+ + " where PROPERTY_ID=? order by ORDER_NUM";
- FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from
JCR_MVALUE where PROPERTY_ID=?";
+ FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID =
+ "select distinct STORAGE_DESC from " + JCR_VALUE + " where
PROPERTY_ID=?";
FIND_VALUE_BY_PROPERTYID_OREDERNUMB =
- "select DATA, STORAGE_DESC from JCR_MVALUE where PROPERTY_ID=? and
ORDER_NUM=?";
+ "select DATA, STORAGE_DESC from " + JCR_VALUE + " where
PROPERTY_ID=? and ORDER_NUM=?";
- FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where
I_CLASS=1 and PARENT_ID=?" + " order by N_ORDER_NUM";
+ FIND_NODES_BY_PARENTID =
+ "select * from " + JCR_ITEM + " where I_CLASS=1 and
PARENT_ID=?" + " order by N_ORDER_NUM";
FIND_NODES_BY_PARENTID_CQ = FIND_NODES_BY_PARENTID_CQ_QUERY;
FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ =
- "select I.NAME, V.DATA, V.ORDER_NUM from JCR_MITEM I, JCR_MVALUE V"
+ "select I.NAME, V.DATA, V.ORDER_NUM from " + JCR_ITEM + " I,
" + JCR_VALUE + " V"
+ " where I.I_CLASS=2 and I.PARENT_ID=? and
(
I.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or"
+ "
I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or"
+ "
I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'
or"
@@ -164,72 +155,78 @@
FIND_ITEM_QPATH_BY_ID_CQ = FIND_ITEM_QPATH_BY_ID_CQ_QUERY;
FIND_LAST_ORDER_NUMBER_BY_PARENTID =
- "select count(*), max(N_ORDER_NUM) from JCR_MITEM where I_CLASS=1 and
PARENT_ID=?";
+ "select count(*), max(N_ORDER_NUM) from " + JCR_ITEM + " where
I_CLASS=1 and PARENT_ID=?";
- FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + "
where I_CLASS=1 and PARENT_ID=?";
+ FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from " + JCR_ITEM +
" where I_CLASS=1 and PARENT_ID=?";
- FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where
I_CLASS=2 and PARENT_ID=?" + " order by NAME";
+ FIND_PROPERTIES_BY_PARENTID = "select * from " + JCR_ITEM + " where
I_CLASS=2 and PARENT_ID=?" + " order by NAME";
// property may contain no values
FIND_PROPERTIES_BY_PARENTID_CQ = FIND_PROPERTIES_BY_PARENTID_CQ_QUERY;
FIND_PROPERTIES_BY_PARENTID_AND_PATTERN_CQ_TEMPLATE =
"select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX,
I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED,"
- + " V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT OUTER JOIN
JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)";
+ + " V.ORDER_NUM, V.DATA, V.STORAGE_DESC from " + JCR_ITEM + "
I LEFT OUTER JOIN " + JCR_VALUE
+ + " V ON (V.PROPERTY_ID=I.ID)";
FIND_NODES_BY_PARENTID_AND_PATTERN_CQ_TEMPLATE =
- "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA from JCR_MITEM I,
JCR_MITEM P, JCR_MVALUE V";
+ "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA from " +
JCR_ITEM + " I, " + JCR_ITEM + " P, "
+ + JCR_VALUE + " V";
FIND_MAX_PROPERTY_VERSIONS =
"select max(VERSION) FROM JCR_MITEM WHERE PARENT_ID=? and NAME=? and
I_INDEX=? and I_CLASS=2";
INSERT_NODE =
- "insert into JCR_MITEM(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX,
N_ORDER_NUM) VALUES(?,?,?,?,"
+ "insert into " + JCR_ITEM + " (ID, PARENT_ID, NAME, VERSION,
I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,"
+ I_CLASS_NODE + ",?,?)";
INSERT_PROPERTY =
- "insert into JCR_MITEM(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX,
P_TYPE, P_MULTIVALUED) VALUES(?,?,?,?,"
+ "insert into " + JCR_ITEM
+ + "(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, P_TYPE,
P_MULTIVALUED) VALUES(?,?,?,?,"
+ I_CLASS_PROPERTY + ",?,?,?)";
- INSERT_VALUE = "insert into JCR_MVALUE(DATA, ORDER_NUM, PROPERTY_ID,
STORAGE_DESC) VALUES(?,?,?,?)";
- INSERT_REF = "insert into JCR_MREF(NODE_ID, PROPERTY_ID, ORDER_NUM)
VALUES(?,?,?)";
+ INSERT_VALUE = "insert into " + JCR_VALUE + "(DATA, ORDER_NUM,
PROPERTY_ID, STORAGE_DESC) VALUES(?,?,?,?)";
+ INSERT_REF = "insert into " + JCR_REF + "(NODE_ID, PROPERTY_ID,
ORDER_NUM) VALUES(?,?,?)";
- RENAME_NODE = "update JCR_MITEM set PARENT_ID=?, NAME =?, VERSION=?, I_INDEX
=?, N_ORDER_NUM =? where ID=?";
+ RENAME_NODE =
+ "update " + JCR_ITEM + " set PARENT_ID=?, NAME =?, VERSION=?,
I_INDEX =?, N_ORDER_NUM =? where ID=?";
- UPDATE_NODE = "update JCR_MITEM set VERSION=?, I_INDEX=?, N_ORDER_NUM=? where
ID=?";
- UPDATE_PROPERTY = "update JCR_MITEM set VERSION=?, P_TYPE=? where ID=?";
- //UPDATE_VALUE = "update JCR_MVALUE set DATA=?, STORAGE_DESC=? where
PROPERTY_ID=?, ORDER_NUM=?";
+ UPDATE_NODE = "update " + JCR_ITEM + " set VERSION=?, I_INDEX=?,
N_ORDER_NUM=? where ID=?";
+ UPDATE_PROPERTY = "update " + JCR_ITEM + " set VERSION=?, P_TYPE=?
where ID=?";
+ //UPDATE_VALUE = "update "+JCR_VALUE+" set DATA=?, STORAGE_DESC=?
where PROPERTY_ID=?, ORDER_NUM=?";
- DELETE_ITEM = "delete from JCR_MITEM where ID=?";
- DELETE_VALUE = "delete from JCR_MVALUE where PROPERTY_ID=?";
- DELETE_REF = "delete from JCR_MREF where PROPERTY_ID=?";
+ DELETE_ITEM = "delete from " + JCR_ITEM + " where ID=?";
+ DELETE_VALUE = "delete from " + JCR_VALUE + " where
PROPERTY_ID=?";
+ DELETE_REF = "delete from " + JCR_REF + " where
PROPERTY_ID=?";
FIND_NODES_AND_PROPERTIES =
"select J.*, P.ID AS P_ID, P.NAME AS P_NAME, P.VERSION AS P_VERSION,
P.P_TYPE, P.P_MULTIVALUED,"
- + " V.DATA, V.ORDER_NUM, V.STORAGE_DESC from JCR_MVALUE V, JCR_MITEM
P"
- + " join (select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_INDEX,
I.N_ORDER_NUM from JCR_MITEM I"
+ + " V.DATA, V.ORDER_NUM, V.STORAGE_DESC from " + JCR_VALUE + "
V, " + JCR_ITEM + " P"
+ + " join (select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_INDEX,
I.N_ORDER_NUM from " + JCR_ITEM + " I"
+ " where I.I_CLASS=1 AND I.ID > ? order by I.ID LIMIT ? OFFSET ?) J
on P.PARENT_ID = J.ID"
+ " where P.I_CLASS=2 and V.PROPERTY_ID=P.ID order by J.ID";
FIND_PROPERTY_BY_ID =
- "select I.P_TYPE, V.STORAGE_DESC from JCR_MITEM I, JCR_MVALUE V where I.ID
= ? and V.PROPERTY_ID = I.ID";
- DELETE_VALUE_BY_ORDER_NUM = "delete from JCR_MVALUE where PROPERTY_ID=? and
ORDER_NUM >= ?";
- UPDATE_VALUE = "update JCR_MVALUE set DATA=?, STORAGE_DESC=? where
PROPERTY_ID=? and ORDER_NUM=?";
+ "select I.P_TYPE, V.STORAGE_DESC from " + JCR_ITEM + " I, "
+ JCR_VALUE
+ + " V where I.ID = ? and V.PROPERTY_ID = I.ID";
+ DELETE_VALUE_BY_ORDER_NUM = "delete from " + JCR_VALUE + " where
PROPERTY_ID=? and ORDER_NUM >= ?";
+ UPDATE_VALUE = "update " + JCR_VALUE + " set DATA=?, STORAGE_DESC=?
where PROPERTY_ID=? and ORDER_NUM=?";
FIND_NODES_BY_PARENTID_LAZILY_CQ =
- "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA from JCR_MITEM I,
JCR_MITEM P, JCR_MVALUE V"
+ "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA from " +
JCR_ITEM + " I, " + JCR_ITEM + " P, "
+ + JCR_VALUE + " V"
+ " where I.I_CLASS=1 and I.PARENT_ID=? and I.N_ORDER_NUM >= ? and
I.N_ORDER_NUM <= ? and"
+ " P.I_CLASS=2 and P.PARENT_ID=I.ID and
(
P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or"
+ "
P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or"
+ "
P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'
or"
+ "
P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')"
+ " and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID";
-
+
FIND_ACL_HOLDERS =
- "select I.PARENT_ID, I.P_TYPE "
- + " from JCR_MITEM I where I.I_CLASS=2 and
(
I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'"
+ "select I.PARENT_ID, I.P_TYPE " + " from " + JCR_ITEM
+ + " I where I.I_CLASS=2 and
(
I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'"
+ " or
I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')";
-
- FIND_NODES_COUNT = "select count(*) from JCR_MITEM I where I.I_CLASS=1";
+
+ FIND_NODES_COUNT = "select count(*) from " + JCR_ITEM + " I where
I.I_CLASS=1";
}
/**
@@ -248,8 +245,8 @@
}
insertNode.setString(1, data.getIdentifier());
- insertNode.setString(2, data.getParentIdentifier() == null ?
Constants.ROOT_PARENT_UUID : data
- .getParentIdentifier());
+ insertNode.setString(2,
+ data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID :
data.getParentIdentifier());
insertNode.setString(3, data.getQPath().getName().getAsString());
insertNode.setInt(4, data.getPersistedVersion());
insertNode.setInt(5, data.getQPath().getIndex());
@@ -705,7 +702,7 @@
insertValue.setString(3, cid);
return insertValue.executeUpdate();
}
-
+
/**
* {@inheritDoc}
*/
@@ -779,8 +776,8 @@
renameNode.clearParameters();
}
- renameNode.setString(1, data.getParentIdentifier() == null ?
Constants.ROOT_PARENT_UUID : data
- .getParentIdentifier());
+ renameNode.setString(1,
+ data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID :
data.getParentIdentifier());
renameNode.setString(2, data.getQPath().getName().getAsString());
renameNode.setInt(3, data.getPersistedVersion());
renameNode.setInt(4, data.getQPath().getIndex());
@@ -1048,12 +1045,12 @@
try
{
removeValuesStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_MVALUE WHERE PROPERTY_ID
IN"
- + " (SELECT ID FROM JCR_MITEM WHERE NAME =
'[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ dbConnection.prepareStatement("DELETE FROM " + JCR_VALUE + "
WHERE PROPERTY_ID IN" + " (SELECT ID FROM "
+ + JCR_ITEM + " WHERE NAME =
'[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
removeItemsStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_MITEM WHERE"
+ dbConnection.prepareStatement("DELETE FROM " + JCR_ITEM + "
WHERE"
+ " NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'");
@@ -1099,13 +1096,12 @@
try
{
removeValuesStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_MVALUE WHERE PROPERTY_ID
IN"
- + " (SELECT ID FROM JCR_MITEM WHERE PARENT_ID=? AND"
- + " (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep'
OR"
+ dbConnection.prepareStatement("DELETE FROM " + JCR_VALUE + "
WHERE PROPERTY_ID IN" + " (SELECT ID FROM "
+ + JCR_ITEM + " WHERE PARENT_ID=? AND" + " (NAME =
'[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'))");
removeItemsStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_MITEM WHERE PARENT_ID=?
AND"
+ dbConnection.prepareStatement("DELETE FROM " + JCR_ITEM + "
WHERE PARENT_ID=? AND"
+ " (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep'
OR"
+ " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
@@ -1156,21 +1152,21 @@
return findNodesCount.executeQuery();
}
- /**
- * {@inheritDoc}
- */
- protected ResultSet findMaxPropertyVersion(String parentId, String name, int index)
throws SQLException
- {
- if (findMaxPropertyVersions == null)
- {
- findMaxPropertyVersions =
dbConnection.prepareStatement(FIND_MAX_PROPERTY_VERSIONS);
- }
+ /**
+ * {@inheritDoc}
+ */
+ protected ResultSet findMaxPropertyVersion(String parentId, String name, int index)
throws SQLException
+ {
+ if (findMaxPropertyVersions == null)
+ {
+ findMaxPropertyVersions =
dbConnection.prepareStatement(FIND_MAX_PROPERTY_VERSIONS);
+ }
- findMaxPropertyVersions.setString(1, getInternalId(parentId));
- findMaxPropertyVersions.setString(2, name);
- findMaxPropertyVersions.setInt(3, index);
+ findMaxPropertyVersions.setString(1, getInternalId(parentId));
+ findMaxPropertyVersions.setString(2, name);
+ findMaxPropertyVersions.setInt(3, index);
- return findMaxPropertyVersions.executeQuery();
- }
+ return findMaxPropertyVersions.executeQuery();
+ }
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLConnectionFactory.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLConnectionFactory.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLConnectionFactory.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -18,11 +18,9 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import java.io.File;
import java.sql.SQLException;
import javax.jcr.RepositoryException;
@@ -41,64 +39,20 @@
/**
* MySQLConnectionFactory constructor.
- *
- *@param dataSource
- * - DataSource
- * @param dbDriver
- * - JDBC Driver
- * @param dbUrl
- * - JDBC URL
- * @param dbUserName
- * - database username
- * @param dbPassword
- * - database user password
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- * @throws RepositoryException
- * if error eccurs
*/
- public MySQLConnectionFactory(String dbDriver, String dbUrl, String dbUserName, String
dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ public MySQLConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
{
- super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ super(containerConfig);
}
/**
* MySQLConnectionFactory constructor.
- *
- * @param dataSource
- * - DataSource
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
*/
- public MySQLConnectionFactory(DataSource dbDataSource, String containerName, boolean
multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public MySQLConnectionFactory(DataSource dbDataSource, JDBCDataContainerConfig
containerConfig)
{
- super(dbDataSource, containerName, multiDb, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbDataSource, containerConfig);
}
/**
@@ -110,14 +64,12 @@
try
{
- if (multiDb)
+ if (this.containerConfig.dbStructureType.isSimpleTable())
{
- return new MySQLMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new MySQLMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
- return new MySQLSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new MySQLSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
catch (SQLException e)
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLMultiDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLMultiDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLMultiDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -20,10 +20,8 @@
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -45,29 +43,17 @@
* MySQL Multidatabase JDBC Connection constructor.
*
* @param dbConnection
- * JDBC connection, shoudl be opened before
+ * JDBC connection, should be opened before
* @param readOnly
* boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName
- * Workspace Storage Container name (see configuration)
- * @param valueStorageProvider
- * External Value Storages provider
- * @param maxBufferSize
- * Maximum buffer size (see configuration)
- * @param swapDirectory
- * Swap directory File (see configuration)
- * @param swapCleaner
- * Swap cleaner (internal FileCleaner).
- * @throws SQLException
- *
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ * @param containerConfig
+ * Workspace Storage Container configuration
*/
- public MySQLMultiDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public MySQLMultiDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -80,12 +66,13 @@
FIND_NODES_AND_PROPERTIES =
"select J.*, P.ID AS P_ID, P.NAME AS P_NAME, P.VERSION AS P_VERSION,
P.P_TYPE, P.P_MULTIVALUED,"
- + " V.DATA, V.ORDER_NUM, V.STORAGE_DESC from JCR_MVALUE V, JCR_MITEM
P"
- + " join (select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_INDEX,
I.N_ORDER_NUM from JCR_MITEM I force index(PRIMARY)"
+ + " V.DATA, V.ORDER_NUM, V.STORAGE_DESC from " + JCR_VALUE + "
V, " + JCR_ITEM + " P"
+ + " join (select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_INDEX,
I.N_ORDER_NUM from " + JCR_ITEM
+ + " I force index(PRIMARY)"
+ " where I.I_CLASS=1 AND I.ID > ? order by I.ID LIMIT ? OFFSET ?) J
on P.PARENT_ID = J.ID"
+ " where P.I_CLASS=2 and V.PROPERTY_ID=P.ID order by J.ID";
- FIND_ITEM_BY_NAME = "select * from JCR_MITEM where PARENT_ID=? and NAME=? and
I_INDEX=? order by I_CLASS";
+ FIND_ITEM_BY_NAME = "select * from " + JCR_ITEM + " where
PARENT_ID=? and NAME=? and I_INDEX=? order by I_CLASS";
}
/**
@@ -101,7 +88,9 @@
try
{
if (!item.next())
+ {
throw new SQLException("Parent is not found. Behaviour of " +
JCR_FK_ITEM_PARENT);
+ }
}
finally
{
@@ -131,7 +120,9 @@
try
{
if (!item.next())
+ {
throw new SQLException("Parent is not found. Behaviour of " +
JCR_FK_ITEM_PARENT);
+ }
}
finally
{
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLSingleDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLSingleDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLSingleDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -20,10 +20,8 @@
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -45,29 +43,17 @@
* MySQL Singledatabase JDBC Connection constructor.
*
* @param dbConnection
- * JDBC connection, shoudl be opened before
+ * JDBC connection, should be opened before
* @param readOnly
* boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName
- * Workspace Storage Container name (see configuration)
- * @param valueStorageProvider
- * External Value Storages provider
- * @param maxBufferSize
- * Maximum buffer size (see configuration)
- * @param swapDirectory
- * Swap directory File (see configuration)
- * @param swapCleaner
- * Swap cleaner (internal FileCleaner).
- * @throws SQLException
- *
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ * @param containerConfig
+ * Workspace Storage Container configuration
*/
- public MySQLSingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public MySQLSingleDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -104,7 +90,9 @@
try
{
if (!item.next())
+ {
throw new SQLException("Parent is not found. Behaviour of " +
JCR_FK_ITEM_PARENT);
+ }
}
finally
{
@@ -134,7 +122,9 @@
try
{
if (!item.next())
+ {
throw new SQLException("Parent is not found. Behaviour of " +
JCR_FK_ITEM_PARENT);
+ }
}
finally
{
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -19,10 +19,8 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
import org.exoplatform.commons.utils.ClassLoading;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -57,35 +55,8 @@
/**
* OracleConnectionFactory constructor. For CLI interface ONLY!
- *
- * @param dbDriver
- * - JDBC Driver
- * @param dbUrl
- * - JDBC URL
- * @param dbUserName
- * - database username
- * @param dbPassword
- * - database user password
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- * @param forceQueryHints
- * - use Oracle queries with query hints
- * @throws RepositoryException
- * if error occurs
*/
- public OracleConnectionFactory(String dbDriver, String dbUrl, String dbUserName,
String dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner, boolean forceQueryHints) throws
RepositoryException
+ public OracleConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
{
// ;D:\Devel\oracle_instantclient_10_2\;C:\oracle\ora92\bin;
@@ -113,8 +84,7 @@
* (OracleOCIConnectionPool.java:893)
*/
- super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner, forceQueryHints);
+ super(containerConfig);
Object cds = null;
try
@@ -132,13 +102,13 @@
prop.setProperty("AbandonedConnectionTimeout",
String.valueOf(CONNCACHE_ABADONDED_TIMEOUT));
Method setURL = cds.getClass().getMethod("setURL", new
Class[]{String.class});
- setURL.invoke(cds, new Object[]{this.dbUrl});
+ setURL.invoke(cds, new Object[]{this.containerConfig.dbUrl});
Method setUser = cds.getClass().getMethod("setUser", new
Class[]{String.class});
- setUser.invoke(cds, new Object[]{this.dbUserName});
+ setUser.invoke(cds, new Object[]{this.containerConfig.dbUserName});
Method setPassword = cds.getClass().getMethod("setPassword", new
Class[]{String.class});
- setPassword.invoke(cds, new Object[]{this.dbPassword});
+ setPassword.invoke(cds, new Object[]{this.containerConfig.dbPassword});
Method setConnectionCachingEnabled =
cds.getClass().getMethod("setConnectionCachingEnabled", new
Class[]{boolean.class});
@@ -149,22 +119,26 @@
setConnectionCacheProperties.invoke(cds, new Object[]{prop});
Method setConnectionCacheName =
cds.getClass().getMethod("setConnectionCacheName", new Class[]{String.class});
- setConnectionCacheName.invoke(cds, new Object[]{"EXOJCR_OCI__" +
containerName});
+ setConnectionCacheName.invoke(cds, new Object[]{"EXOJCR_OCI__" +
containerConfig.containerName});
}
catch (Throwable e)
{
cds = null;
- StringBuilder err = new StringBuilder("Oracle OCI connection cache is
unavailable due to error ").append(e);
+ StringBuilder err = new StringBuilder("Oracle OCI connection cache is
unavailable due to error ").append(e);
if (e.getCause() != null)
{
err.append(" (").append(e.getCause()).append(")");
}
err.append(". Standard JDBC DriverManager will be used for connections
opening.");
if (log.isDebugEnabled())
+ {
log.warn(err, e);
+ }
else
+ {
log.warn(err);
+ }
}
this.ociDataSource = cds; // actually instance of javax.sql.DataSource
}
@@ -176,6 +150,7 @@
public Connection getJdbcConnection(boolean readOnly) throws RepositoryException
{
if (ociDataSource != null)
+ {
try
{
Connection conn = getCachedConnection();
@@ -192,6 +167,7 @@
{
throw new RepositoryException("Oracle OCI cached connection open error
" + e, e);
}
+ }
return super.getJdbcConnection(readOnly);
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleMultiDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleMultiDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleMultiDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -16,10 +16,8 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -33,47 +31,27 @@
public class OracleMultiDbJDBCConnection extends MultiDbJDBCConnection
{
- protected static final String FIND_NODES_BY_PARENTID_CQ_QUERY =
- MultiDbJDBCConnection.FIND_NODES_BY_PARENTID_CQ_QUERY
- .replaceFirst("select",
- "select /*+ INDEX(I JCR_IDX_MITEM_PARENT_ID) INDEX(P
JCR_IDX_MITEM_PARENT_ID) INDEX(V JCR_IDX_MVALUE_PROPERTY)*/");
+ protected String FIND_NODES_BY_PARENTID_CQ_QUERY;
- protected static final String FIND_PROPERTIES_BY_PARENTID_CQ_QUERY =
-
MultiDbJDBCConnection.FIND_PROPERTIES_BY_PARENTID_CQ_QUERY.replaceFirst("select",
- "select /*+ INDEX(I JCR_IDX_MITEM_PARENT_ID) INDEX(V
JCR_IDX_MVALUE_PROPERTY)*/");
-
- protected static final String FIND_ITEM_QPATH_BY_ID_CQ_QUERY =
-
MultiDbJDBCConnection.FIND_ITEM_QPATH_BY_ID_CQ_QUERY.replaceFirst("SELECT",
- "SELECT /*+ INDEX(JCR_MITEM JCR_PK_MITEM) */");
+ protected String FIND_PROPERTIES_BY_PARENTID_CQ_QUERY;
+ protected String FIND_ITEM_QPATH_BY_ID_CQ_QUERY;
/**
* Oracle Multidatabase JDBC Connection constructor.
*
* @param dbConnection
- * JDBC connection, shoudl be opened before
+ * JDBC connection, should be opened before
* @param readOnly
* boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName
- * Workspace Storage Container name (see configuration)
- * @param valueStorageProvider
- * External Value Storages provider
- * @param maxBufferSize
- * Maximum buffer size (see configuration)
- * @param swapDirectory
- * Swap directory File (see configuration)
- * @param swapCleaner
- * Swap cleaner (internal FileCleaner).
- * @throws SQLException
- *
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ * @param containerConfig
+ * Workspace Storage Container configuration
*/
- public OracleMultiDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public OracleMultiDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -83,30 +61,42 @@
protected void prepareQueries() throws SQLException
{
super.prepareQueries();
+
+ FIND_NODES_BY_PARENTID_CQ_QUERY =
+ super.FIND_NODES_BY_PARENTID_CQ_QUERY.replaceFirst("select",
"select /*+ INDEX(I " + JCR_IDX_ITEM_PARENT_ID
+ + ") INDEX(P " + JCR_IDX_ITEM_PARENT_ID + ") INDEX(V " +
JCR_IDX_VALUE_PROPERTY + ")*/");
+
+ FIND_PROPERTIES_BY_PARENTID_CQ_QUERY =
+ super.FIND_PROPERTIES_BY_PARENTID_CQ_QUERY.replaceFirst("select",
"select /*+ INDEX(I "
+ + JCR_IDX_ITEM_PARENT_ID + ") INDEX(V " + JCR_IDX_VALUE_PROPERTY +
")*/");
+
+ FIND_ITEM_QPATH_BY_ID_CQ_QUERY =
+ super.FIND_ITEM_QPATH_BY_ID_CQ_QUERY.replaceFirst("SELECT",
"SELECT /*+ INDEX(" + JCR_ITEM + " " + JCR_PK_ITEM
+ + ") */");
+
FIND_NODES_BY_PARENTID_CQ = FIND_NODES_BY_PARENTID_CQ_QUERY;
FIND_PROPERTIES_BY_PARENTID_CQ = FIND_PROPERTIES_BY_PARENTID_CQ_QUERY;
FIND_ITEM_QPATH_BY_ID_CQ = FIND_ITEM_QPATH_BY_ID_CQ_QUERY;
FIND_PROPERTIES_BY_PARENTID_AND_PATTERN_CQ_TEMPLATE =
- "select /*+ INDEX(I JCR_FK_MITEM_PARENT) INDEX(V
JCR_IDX_MVALUE_PROPERTY)*/"
+ "select /*+ INDEX(I " + JCR_FK_ITEM_PARENT + ") INDEX(V " +
JCR_IDX_VALUE_PROPERTY + ")*/"
+ " I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX,
I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED,"
- + " V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT OUTER JOIN
JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)";
+ + " V.ORDER_NUM, V.DATA, V.STORAGE_DESC from " + JCR_ITEM + "
I LEFT OUTER JOIN " + JCR_VALUE
+ + " V ON (V.PROPERTY_ID=I.ID)";
FIND_NODES_AND_PROPERTIES =
"select J.*, P.ID AS P_ID, P.NAME AS P_NAME, P.VERSION AS P_VERSION,
P.P_TYPE, P.P_MULTIVALUED,"
- + " V.DATA, V.ORDER_NUM, V.STORAGE_DESC from JCR_MVALUE V, JCR_MITEM
P"
+ + " V.DATA, V.ORDER_NUM, V.STORAGE_DESC from " + JCR_VALUE + "
V, " + JCR_ITEM + " P"
+ " join ( select * from ( select A.*, ROWNUM r__ from ("
- + " select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_INDEX,
I.N_ORDER_NUM from JCR_MITEM I "
+ + " select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_INDEX,
I.N_ORDER_NUM from " + JCR_ITEM + " I "
+ " where I.I_CLASS=1 order by I.ID) A where ROWNUM <= ?) where r__
> ?) J on P.PARENT_ID = J.ID"
+ " where P.I_CLASS=2 and V.PROPERTY_ID=P.ID order by J.ID";
-
+
FIND_NODES_BY_PARENTID_LAZILY_CQ =
- FIND_NODES_BY_PARENTID_LAZILY_CQ
- .replaceFirst(
- "select",
- "select /*+ USE_NL(V) INDEX(I JCR_IDX_MITEM_N_ORDER_NUM) INDEX(P
JCR_IDX_MITEM_PARENT_FK)"
- + " INDEX(V JCR_IDX_MVALUE_PROPERTY) */");
+ FIND_NODES_BY_PARENTID_LAZILY_CQ.replaceFirst("select", "select
/*+ USE_NL(V) INDEX(I "
+ + JCR_IDX_ITEM_N_ORDER_NUM + ") INDEX(P " + JCR_IDX_ITEM_PARENT_FK
+ ") INDEX(V " + JCR_IDX_VALUE_PROPERTY
+ + ") */");
}
-
+
/**
* {@inheritDoc}
*/
@@ -126,5 +116,5 @@
findNodesAndProperties.setInt(2, offset);
return findNodesAndProperties.executeQuery();
- }
+ }
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OraclePoolConnectionFactory.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OraclePoolConnectionFactory.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OraclePoolConnectionFactory.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -19,10 +19,8 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
import org.exoplatform.commons.utils.ClassLoading;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -52,33 +50,8 @@
/**
* OraclePoolConnectionFactory constructor. For CLI interface ONLY!
- *
- * @param dbDriver
- * - JDBC Driver
- * @param dbUrl
- * - JDBC URL
- * @param dbUserName
- * - database username
- * @param dbPassword
- * - database user password
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- * @throws RepositoryException
- * if error occurs
*/
- public OraclePoolConnectionFactory(String dbDriver, String dbUrl, String dbUserName,
String dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ public OraclePoolConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
{
// ;D:\Devel\oracle_instantclient_10_2\;C:\oracle\ora92\bin;
@@ -106,8 +79,7 @@
* (OracleOCIConnectionPool.java:893)
*/
- super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ super(containerConfig);
Object cpool = null;
try
@@ -116,7 +88,9 @@
Constructor<?> cpoolConstructor =
cpoolClass.getConstructor(new Class[]{String.class, String.class,
String.class, Properties.class});
- cpool = cpoolConstructor.newInstance(new Object[]{this.dbUserName,
this.dbPassword, this.dbUrl, null});
+ cpool =
+ cpoolConstructor.newInstance(new Object[]{this.containerConfig.dbUserName,
this.containerConfig.dbPassword,
+ this.containerConfig.dbUrl, null});
Method setConnectionCachingEnabled =
cpool.getClass().getMethod("setConnectionCachingEnabled", new
Class[]{boolean.class});
setConnectionCachingEnabled.invoke(cpool, new Object[]{true});
@@ -131,9 +105,13 @@
}
err.append(". Standard JDBC DriverManager will be used for connections
opening.");
if (log.isDebugEnabled())
+ {
log.warn(err, e);
+ }
else
+ {
log.warn(err);
+ }
}
this.ociPool = cpool;
@@ -146,9 +124,13 @@
catch (Throwable e)
{
if (log.isDebugEnabled())
+ {
log.warn("Oracle OCI connection pool configuration error " + e,
e);
+ }
else
+ {
log.warn("Oracle OCI connection pool configuration error " + e);
+ }
}
}
@@ -159,6 +141,7 @@
public Connection getJdbcConnection(boolean readOnly) throws RepositoryException
{
if (ociPool != null)
+ {
try
{
Connection conn = getPoolConnection();
@@ -175,6 +158,7 @@
{
throw new RepositoryException("Oracle OCI pool connection open error
" + e, e);
}
+ }
return super.getJdbcConnection(readOnly);
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleSingleDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleSingleDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleSingleDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -16,10 +16,8 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -53,26 +51,14 @@
* JDBC connection, should be opened before
* @param readOnly
* boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName
- * Workspace Storage Container name (see configuration)
- * @param valueStorageProvider
- * External Value Storages provider
- * @param maxBufferSize
- * Maximum buffer size (see configuration)
- * @param swapDirectory
- * Swap directory File (see configuration)
- * @param swapCleaner
- * Swap cleaner (internal FileCleaner).
- * @throws SQLException
- *
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ * @param containerConfig
+ * Workspace Storage Container configuration
*/
- public OracleSingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public OracleSingleDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -123,10 +109,10 @@
findNodesAndProperties.clearParameters();
}
- findNodesAndProperties.setString(1, containerName);
+ findNodesAndProperties.setString(1, this.containerConfig.containerName);
findNodesAndProperties.setInt(2, offset + limit);
findNodesAndProperties.setInt(3, offset);
- findNodesAndProperties.setString(4, containerName);
+ findNodesAndProperties.setString(4, this.containerConfig.containerName);
return findNodesAndProperties.executeQuery();
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/PostgreConnectionFactory.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/PostgreConnectionFactory.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/PostgreConnectionFactory.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -16,11 +16,9 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import java.io.File;
import java.sql.SQLException;
import javax.jcr.RepositoryException;
@@ -38,64 +36,18 @@
{
/**
* PostgreConnectionFactory constructor.
- *
- *@param dataSource
- * - DataSource
- * @param dbDriver
- * - JDBC Driver
- * @param dbUrl
- * - JDBC URL
- * @param dbUserName
- * - database username
- * @param dbPassword
- * - database user password
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- * @throws RepositoryException
- * if error eccurs
*/
- public PostgreConnectionFactory(String dbDriver, String dbUrl, String dbUserName,
String dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ public PostgreConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
{
-
- super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ super(containerConfig);
}
/**
* PostgreConnectionFactory constructor.
- *
- * @param dataSource
- * - DataSource
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
*/
- public PostgreConnectionFactory(DataSource dbDataSource, String containerName, boolean
multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public PostgreConnectionFactory(DataSource dbDataSource, JDBCDataContainerConfig
containerConfig)
{
-
- super(dbDataSource, containerName, multiDb, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbDataSource, containerConfig);
}
/**
@@ -106,23 +58,19 @@
{
try
{
-
- if (multiDb)
+ if (this.containerConfig.dbStructureType.isSimpleTable())
{
- return new PostgreMultiDbJDBCConnection(getJdbcConnection(readOnly),
readOnly, containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new PostgreMultiDbJDBCConnection(getJdbcConnection(readOnly),
readOnly, containerConfig);
}
- return new PostgreSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
-
+ return new PostgreSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
catch (SQLException e)
{
throw new RepositoryException(e);
}
}
-
+
/**
* {@inheritDoc}
*/
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/PostgreMultiDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/PostgreMultiDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/PostgreMultiDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -16,10 +16,8 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.sql.Connection;
import java.sql.SQLException;
@@ -35,11 +33,18 @@
{
protected String PATTERN_ESCAPE_STRING = "\\\\";
- public PostgreMultiDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
- throws SQLException
+ /**
+ * @param dbConnection
+ * JDBC connection, should be opened before
+ * @param readOnly
+ * boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerConfig
+ * Workspace Storage Container configuration
+ */
+ public PostgreMultiDbJDBCConnection(Connection dbConnection, boolean readOnly,
+ JDBCDataContainerConfig containerConfig) throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/PostgreSingleDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/PostgreSingleDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/PostgreSingleDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -16,10 +16,8 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import java.io.File;
import java.sql.Connection;
import java.sql.SQLException;
@@ -35,11 +33,18 @@
{
protected static final String PATTERN_ESCAPE_STRING = "\\\\";
- public PostgreSingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ /**
+ * @param dbConnection
+ * JDBC connection, should be opened before
+ * @param readOnly
+ * boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerConfig
+ * Workspace Storage Container configuration
+ */
+ public PostgreSingleDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -24,11 +24,9 @@
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.itemfilters.QPathEntryFilter;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCStorageConnection;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
@@ -65,33 +63,28 @@
"select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX,
I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED, V.ORDER_NUM,"
+ " V.DATA, V.STORAGE_DESC from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON
(V.PROPERTY_ID=I.ID)"
+ " where I.I_CLASS=2 and I.CONTAINER_NAME=? and I.PARENT_ID=? order by
I.NAME";
-
- protected static final String FIND_ITEM_QPATH_BY_ID_CQ_QUERY =
- "select I.ID, I.PARENT_ID, I.NAME, I.I_INDEX"
- + " from JCR_SITEM I, (SELECT ID, PARENT_ID from JCR_SITEM where ID=?)
J"
- + " where I.ID = J.ID or I.ID = J.PARENT_ID";
+ protected static final String FIND_ITEM_QPATH_BY_ID_CQ_QUERY = "select I.ID,
I.PARENT_ID, I.NAME, I.I_INDEX"
+ + " from JCR_SITEM I, (SELECT ID, PARENT_ID from JCR_SITEM where ID=?)
J"
+ + " where I.ID = J.ID or I.ID = J.PARENT_ID";
+
protected static final String PATTERN_ESCAPE_STRING = "\\"; //valid for
HSQL, Sybase, DB2, MSSQL, ORACLE
/**
* Singledatabase JDBC Connection constructor.
*
- * @param dbConnection JDBC connection, shoudl be opened before
- * @param readOnly, boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName Workspace Storage Container name (see configuration)
- * @param valueStorageProvider External Value Storages provider
- * @param maxBufferSize Maximum buffer size (see configuration)
- * @param swapDirectory Swap directory (see configuration)
- * @param swapCleaner Swap cleaner (internal FileCleaner).
- * @throws SQLException in case of database error
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ * @param dbConnection
+ * JDBC connection, should be opened before
+ * @param readOnly
+ * boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerConfig
+ * Workspace Storage Container configuration
*/
- public SingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public SingleDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -100,7 +93,7 @@
@Override
protected String getInternalId(final String identifier)
{
- return containerName + identifier;
+ return this.containerConfig.containerName + identifier;
}
/**
@@ -110,10 +103,12 @@
protected String getIdentifier(final String internalId)
{
- if (internalId == null) // possible for root parent
+ if (internalId == null)
+ {
return null;
+ }
- return internalId.substring(containerName.length());
+ return internalId.substring(this.containerConfig.containerName.length());
}
/**
@@ -123,16 +118,6 @@
protected void prepareQueries() throws SQLException
{
- JCR_PK_ITEM = "JCR_PK_SITEM";
- JCR_FK_ITEM_PARENT = "JCR_FK_SITEM_PARENT";
- JCR_IDX_ITEM_PARENT = "JCR_IDX_SITEM_PARENT";
- JCR_IDX_ITEM_PARENT_ID = "JCR_IDX_SITEM_PARENT_ID";
- JCR_PK_VALUE = "JCR_PK_SVALUE";
- JCR_FK_VALUE_PROPERTY = "JCR_FK_SVALUE_PROPERTY";
- JCR_IDX_VALUE_PROPERTY = "JCR_IDX_SVALUE_PROPERTY";
- JCR_PK_REF = "JCR_PK_SREF";
- JCR_IDX_REF_PROPERTY = "JCR_IDX_SREF_PROPERTY";
-
FIND_ITEM_BY_ID = "select * from JCR_SITEM where ID=?";
FIND_ITEM_BY_NAME =
@@ -232,9 +217,9 @@
+ "
P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'
or"
+ "
P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')"
+ " and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID";
-
- FIND_ACL_HOLDERS = "select I.PARENT_ID, I.P_TYPE"
- + " from JCR_SITEM I where I.I_CLASS=2 and I.CONTAINER_NAME=?"
+
+ FIND_ACL_HOLDERS =
+ "select I.PARENT_ID, I.P_TYPE" + " from JCR_SITEM I where
I.I_CLASS=2 and I.CONTAINER_NAME=?"
+ " and
(
I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'"
+ " or
I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')";
@@ -248,16 +233,20 @@
protected int addNodeRecord(NodeData data) throws SQLException
{
if (insertNode == null)
+ {
insertNode = dbConnection.prepareStatement(INSERT_NODE);
+ }
else
+ {
insertNode.clearParameters();
+ }
insertNode.setString(1, getInternalId(data.getIdentifier()));
// if root then parent identifier equals space string
- insertNode.setString(2, data.getParentIdentifier() == null ?
Constants.ROOT_PARENT_UUID : getInternalId(data
- .getParentIdentifier()));
+ insertNode.setString(2,
+ data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID :
getInternalId(data.getParentIdentifier()));
insertNode.setString(3, data.getQPath().getName().getAsString());
- insertNode.setString(4, containerName);
+ insertNode.setString(4, this.containerConfig.containerName);
insertNode.setInt(5, data.getPersistedVersion());
insertNode.setInt(6, data.getQPath().getIndex());
insertNode.setInt(7, data.getOrderNumber());
@@ -271,14 +260,18 @@
protected int addPropertyRecord(PropertyData data) throws SQLException
{
if (insertProperty == null)
+ {
insertProperty = dbConnection.prepareStatement(INSERT_PROPERTY);
+ }
else
+ {
insertProperty.clearParameters();
+ }
insertProperty.setString(1, getInternalId(data.getIdentifier()));
insertProperty.setString(2, getInternalId(data.getParentIdentifier()));
insertProperty.setString(3, data.getQPath().getName().getAsString());
- insertProperty.setString(4, containerName);
+ insertProperty.setString(4, this.containerConfig.containerName);
insertProperty.setInt(5, data.getPersistedVersion());
insertProperty.setInt(6, data.getQPath().getIndex());
insertProperty.setInt(7, data.getType());
@@ -294,9 +287,13 @@
protected int addReference(PropertyData data) throws SQLException, IOException
{
if (insertReference == null)
+ {
insertReference = dbConnection.prepareStatement(INSERT_REF);
+ }
else
+ {
insertReference.clearParameters();
+ }
List<ValueData> values = data.getValues();
int added = 0;
@@ -320,9 +317,13 @@
protected int deleteReference(String propertyCid) throws SQLException
{
if (deleteReference == null)
+ {
deleteReference = dbConnection.prepareStatement(DELETE_REF);
+ }
else
+ {
deleteReference.clearParameters();
+ }
deleteReference.setString(1, propertyCid);
return deleteReference.executeUpdate();
@@ -335,9 +336,13 @@
protected int deleteItemByIdentifier(String cid) throws SQLException
{
if (deleteItem == null)
+ {
deleteItem = dbConnection.prepareStatement(DELETE_ITEM);
+ }
else
+ {
deleteItem.clearParameters();
+ }
deleteItem.setString(1, cid);
return deleteItem.executeUpdate();
@@ -350,11 +355,15 @@
protected ResultSet findChildNodesByParentIdentifier(String parentCid) throws
SQLException
{
if (findNodesByParentId == null)
+ {
findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
+ }
else
+ {
findNodesByParentId.clearParameters();
+ }
- findNodesByParentId.setString(1, containerName);
+ findNodesByParentId.setString(1, this.containerConfig.containerName);
findNodesByParentId.setString(2, parentCid);
return findNodesByParentId.executeQuery();
}
@@ -366,11 +375,15 @@
protected ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier)
throws SQLException
{
if (findLastOrderNumberByParentId == null)
+ {
findLastOrderNumberByParentId =
dbConnection.prepareStatement(FIND_LAST_ORDER_NUMBER_BY_PARENTID);
+ }
else
+ {
findLastOrderNumberByParentId.clearParameters();
+ }
- findLastOrderNumberByParentId.setString(1, containerName);
+ findLastOrderNumberByParentId.setString(1, this.containerConfig.containerName);
findLastOrderNumberByParentId.setString(2, parentIdentifier);
return findLastOrderNumberByParentId.executeQuery();
}
@@ -382,11 +395,15 @@
protected ResultSet findChildNodesCountByParentIdentifier(String parentCid) throws
SQLException
{
if (findNodesCountByParentId == null)
+ {
findNodesCountByParentId =
dbConnection.prepareStatement(FIND_NODES_COUNT_BY_PARENTID);
+ }
else
+ {
findNodesCountByParentId.clearParameters();
+ }
- findNodesCountByParentId.setString(1, containerName);
+ findNodesCountByParentId.setString(1, this.containerConfig.containerName);
findNodesCountByParentId.setString(2, parentCid);
return findNodesCountByParentId.executeQuery();
}
@@ -398,11 +415,15 @@
protected ResultSet findChildPropertiesByParentIdentifier(String parentCid) throws
SQLException
{
if (findPropertiesByParentId == null)
+ {
findPropertiesByParentId =
dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
+ }
else
+ {
findPropertiesByParentId.clearParameters();
+ }
- findPropertiesByParentId.setString(1, containerName);
+ findPropertiesByParentId.setString(1, this.containerConfig.containerName);
findPropertiesByParentId.setString(2, parentCid);
return findPropertiesByParentId.executeQuery();
}
@@ -414,11 +435,15 @@
protected ResultSet findItemByName(String parentId, String name, int index) throws
SQLException
{
if (findItemByName == null)
+ {
findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
+ }
else
+ {
findItemByName.clearParameters();
+ }
- findItemByName.setString(1, containerName);
+ findItemByName.setString(1, this.containerConfig.containerName);
findItemByName.setString(2, parentId);
findItemByName.setString(3, name);
findItemByName.setInt(4, index);
@@ -432,11 +457,15 @@
protected ResultSet findPropertyByName(String parentCid, String name) throws
SQLException
{
if (findPropertyByName == null)
+ {
findPropertyByName = dbConnection.prepareStatement(FIND_PROPERTY_BY_NAME);
+ }
else
+ {
findPropertyByName.clearParameters();
+ }
- findPropertyByName.setString(1, containerName);
+ findPropertyByName.setString(1, this.containerConfig.containerName);
findPropertyByName.setString(2, parentCid);
findPropertyByName.setString(3, name);
return findPropertyByName.executeQuery();
@@ -449,9 +478,13 @@
protected ResultSet findItemByIdentifier(String cid) throws SQLException
{
if (findItemById == null)
+ {
findItemById = dbConnection.prepareStatement(FIND_ITEM_BY_ID);
+ }
else
+ {
findItemById.clearParameters();
+ }
findItemById.setString(1, cid);
return findItemById.executeQuery();
@@ -464,12 +497,16 @@
protected ResultSet findReferences(String cid) throws SQLException
{
if (findReferences == null)
+ {
findReferences = dbConnection.prepareStatement(FIND_REFERENCES);
+ }
else
+ {
findReferences.clearParameters();
+ }
findReferences.setString(1, cid);
- findReferences.setString(2, containerName);
+ findReferences.setString(2, this.containerConfig.containerName);
return findReferences.executeQuery();
}
@@ -480,9 +517,13 @@
protected int updateNodeByIdentifier(int version, int index, int orderNumb, String
cid) throws SQLException
{
if (updateNode == null)
+ {
updateNode = dbConnection.prepareStatement(UPDATE_NODE);
+ }
else
+ {
updateNode.clearParameters();
+ }
updateNode.setInt(1, version);
updateNode.setInt(2, index);
@@ -498,9 +539,13 @@
protected int updatePropertyByIdentifier(int version, int type, String cid) throws
SQLException
{
if (updateProperty == null)
+ {
updateProperty = dbConnection.prepareStatement(UPDATE_PROPERTY);
+ }
else
+ {
updateProperty.clearParameters();
+ }
updateProperty.setInt(1, version);
updateProperty.setInt(2, type);
@@ -515,15 +560,19 @@
throws SQLException
{
if (findNodesByParentIdLazilyCQ == null)
+ {
findNodesByParentIdLazilyCQ =
dbConnection.prepareStatement(FIND_NODES_BY_PARENTID_LAZILY_CQ);
+ }
else
+ {
findNodesByParentIdLazilyCQ.clearParameters();
+ }
- findNodesByParentIdLazilyCQ.setString(1, containerName);
+ findNodesByParentIdLazilyCQ.setString(1, this.containerConfig.containerName);
findNodesByParentIdLazilyCQ.setString(2, parentCid);
findNodesByParentIdLazilyCQ.setInt(3, fromOrderNum);
findNodesByParentIdLazilyCQ.setInt(4, toOrderNum);
- findNodesByParentIdLazilyCQ.setString(5, containerName);
+ findNodesByParentIdLazilyCQ.setString(5, this.containerConfig.containerName);
return findNodesByParentIdLazilyCQ.executeQuery();
}
@@ -538,9 +587,13 @@
throws SQLException
{
if (insertValue == null)
+ {
insertValue = dbConnection.prepareStatement(INSERT_VALUE);
+ }
else
+ {
insertValue.clearParameters();
+ }
if (stream == null)
{
@@ -566,9 +619,13 @@
protected int deleteValueData(String cid) throws SQLException
{
if (deleteValue == null)
+ {
deleteValue = dbConnection.prepareStatement(DELETE_VALUE);
+ }
else
+ {
deleteValue.clearParameters();
+ }
deleteValue.setString(1, cid);
return deleteValue.executeUpdate();
@@ -581,9 +638,13 @@
protected ResultSet findValuesByPropertyId(String cid) throws SQLException
{
if (findValuesByPropertyId == null)
+ {
findValuesByPropertyId =
dbConnection.prepareStatement(FIND_VALUES_BY_PROPERTYID);
+ }
else
+ {
findValuesByPropertyId.clearParameters();
+ }
findValuesByPropertyId.setString(1, cid);
return findValuesByPropertyId.executeQuery();
@@ -596,10 +657,14 @@
protected ResultSet findValuesStorageDescriptorsByPropertyId(String cid) throws
SQLException
{
if (findValuesStorageDescriptorsByPropertyId == null)
+ {
findValuesStorageDescriptorsByPropertyId =
dbConnection.prepareStatement(FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID);
+ }
else
+ {
findValuesStorageDescriptorsByPropertyId.clearParameters();
+ }
findValuesStorageDescriptorsByPropertyId.setString(1, cid);
return findValuesStorageDescriptorsByPropertyId.executeQuery();
@@ -632,12 +697,16 @@
protected int renameNode(NodeData data) throws SQLException
{
if (renameNode == null)
+ {
renameNode = dbConnection.prepareStatement(RENAME_NODE);
+ }
else
+ {
renameNode.clearParameters();
+ }
- renameNode.setString(1, data.getParentIdentifier() == null ?
Constants.ROOT_PARENT_UUID : getInternalId(data
- .getParentIdentifier()));
+ renameNode.setString(1,
+ data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID :
getInternalId(data.getParentIdentifier()));
renameNode.setString(2, data.getQPath().getName().getAsString());
renameNode.setInt(3, data.getPersistedVersion());
renameNode.setInt(4, data.getQPath().getIndex());
@@ -653,13 +722,17 @@
protected ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier) throws
SQLException
{
if (findNodesByParentIdCQ == null)
+ {
findNodesByParentIdCQ =
dbConnection.prepareStatement(FIND_NODES_BY_PARENTID_CQ);
+ }
else
+ {
findNodesByParentIdCQ.clearParameters();
+ }
- findNodesByParentIdCQ.setString(1, containerName);
+ findNodesByParentIdCQ.setString(1, this.containerConfig.containerName);
findNodesByParentIdCQ.setString(2, parentIdentifier);
- findNodesByParentIdCQ.setString(3, containerName);
+ findNodesByParentIdCQ.setString(3, this.containerConfig.containerName);
return findNodesByParentIdCQ.executeQuery();
}
@@ -683,7 +756,7 @@
//create query from list
StringBuilder query = new
StringBuilder(FIND_NODES_BY_PARENTID_AND_PATTERN_CQ_TEMPLATE);
query.append(" where I.I_CLASS=1 and I.CONTAINER_NAME='");
- query.append(containerName);
+ query.append(this.containerConfig.containerName);
query.append("' and I.PARENT_ID='");
query.append(parentIdentifier);
query.append("' and ( ");
@@ -694,7 +767,7 @@
appendPattern(query, pattern.get(i).getQPathEntry(), true);
}
query.append(" ) and P.I_CLASS=2 and P.CONTAINER_NAME='");
- query.append(containerName);
+ query.append(this.containerConfig.containerName);
query.append("' and P.PARENT_ID=I.ID and
(
P.NAME='[http://www.jcp.org/jcr/1.0]primaryType'");
query.append(" or
P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes'");
query.append(" or
P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'");
@@ -712,11 +785,15 @@
protected ResultSet findChildPropertiesByParentIdentifierCQ(String parentIdentifier)
throws SQLException
{
if (findPropertiesByParentIdCQ == null)
+ {
findPropertiesByParentIdCQ =
dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID_CQ);
+ }
else
+ {
findPropertiesByParentIdCQ.clearParameters();
+ }
- findPropertiesByParentIdCQ.setString(1, containerName);
+ findPropertiesByParentIdCQ.setString(1, this.containerConfig.containerName);
findPropertiesByParentIdCQ.setString(2, parentIdentifier);
return findPropertiesByParentIdCQ.executeQuery();
@@ -742,7 +819,7 @@
//create query from list
StringBuilder query = new
StringBuilder(FIND_PROPERTIES_BY_PARENTID_AND_PATTERN_CQ_TEMPLATE);
query.append(" where I.I_CLASS=2 and I.CONTAINER_NAME='");
- query.append(containerName);
+ query.append(this.containerConfig.containerName);
query.append("' and I.PARENT_ID='");
query.append(parentCid);
query.append("' and ( ");
@@ -765,12 +842,16 @@
protected ResultSet findNodeMainPropertiesByParentIdentifierCQ(String
parentIdentifier) throws SQLException
{
if (findNodeMainPropertiesByParentIdentifierCQ == null)
+ {
findNodeMainPropertiesByParentIdentifierCQ =
dbConnection.prepareStatement(FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ);
+ }
else
+ {
findNodeMainPropertiesByParentIdentifierCQ.clearParameters();
+ }
- findNodeMainPropertiesByParentIdentifierCQ.setString(1, containerName);
+ findNodeMainPropertiesByParentIdentifierCQ.setString(1,
this.containerConfig.containerName);
findNodeMainPropertiesByParentIdentifierCQ.setString(2, parentIdentifier);
return findNodeMainPropertiesByParentIdentifierCQ.executeQuery();
}
@@ -782,9 +863,13 @@
protected ResultSet findItemQPathByIdentifierCQ(String identifier) throws
SQLException
{
if (findItemQPathByIdentifierCQ == null)
+ {
findItemQPathByIdentifierCQ =
dbConnection.prepareStatement(FIND_ITEM_QPATH_BY_ID_CQ);
+ }
else
+ {
findItemQPathByIdentifierCQ.clearParameters();
+ }
findItemQPathByIdentifierCQ.setString(1, identifier);
return findItemQPathByIdentifierCQ.executeQuery();
@@ -805,49 +890,61 @@
findNodesAndProperties.clearParameters();
}
- findNodesAndProperties.setString(1, containerName);
+ findNodesAndProperties.setString(1, this.containerConfig.containerName);
findNodesAndProperties.setString(2, getInternalId(lastNodeId));
findNodesAndProperties.setInt(3, limit);
findNodesAndProperties.setInt(4, offset);
- findNodesAndProperties.setString(5, containerName);
+ findNodesAndProperties.setString(5, this.containerConfig.containerName);
return findNodesAndProperties.executeQuery();
}
-
+
@Override
protected int deleteValueDataByOrderNum(String id, int orderNum) throws SQLException
{
if (deleteValueDataByOrderNum == null)
+ {
deleteValueDataByOrderNum =
dbConnection.prepareStatement(DELETE_VALUE_BY_ORDER_NUM);
+ }
else
+ {
deleteValueDataByOrderNum.clearParameters();
+ }
deleteValueDataByOrderNum.setString(1, id);
deleteValueDataByOrderNum.setInt(2, orderNum);
return deleteValueDataByOrderNum.executeUpdate();
}
-
+
@Override
protected ResultSet findPropertyById(String id) throws SQLException
{
if (findPropertyById == null)
+ {
findPropertyById = dbConnection.prepareStatement(FIND_PROPERTY_BY_ID);
+ }
else
+ {
findPropertyById.clearParameters();
+ }
findPropertyById.setString(1, id);
return findPropertyById.executeQuery();
}
-
+
@Override
protected int updateValueData(String cid, int orderNumber, InputStream stream, int
streamLength, String storageDesc)
throws SQLException
{
if (updateValue == null)
+ {
updateValue = dbConnection.prepareStatement(UPDATE_VALUE);
+ }
else
+ {
updateValue.clearParameters();
+ }
if (stream == null)
{
@@ -864,7 +961,7 @@
updateValue.setString(3, cid);
updateValue.setInt(4, orderNumber);
return updateValue.executeUpdate();
- }
+ }
/**
* Replace underscore in pattern with escaped symbol. Replace jcr-wildcard '*'
with sql-wildcard '%'.
@@ -954,7 +1051,7 @@
findACLHolders.clearParameters();
}
- findACLHolders.setString(1, containerName);
+ findACLHolders.setString(1, this.containerConfig.containerName);
return findACLHolders.executeQuery();
}
@@ -973,13 +1070,13 @@
dbConnection.prepareStatement("DELETE FROM JCR_SVALUE WHERE PROPERTY_ID
IN (SELECT ID FROM JCR_SITEM"
+ " WHERE CONTAINER_NAME = ? AND (NAME =
'[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'))");
- removeValuesStatement.setString(1, containerName);
+ removeValuesStatement.setString(1, this.containerConfig.containerName);
removeItemsStatement =
dbConnection.prepareStatement("DELETE FROM JCR_SITEM WHERE
CONTAINER_NAME = ? AND"
+ " (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep'
OR"
+ " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
- removeItemsStatement.setString(1, containerName);
+ removeItemsStatement.setString(1, this.containerConfig.containerName);
removeValuesStatement.executeUpdate();
removeItemsStatement.executeUpdate();
@@ -1027,7 +1124,7 @@
findNodesCount.clearParameters();
}
- findNodesCount.setString(1, containerName);
+ findNodesCount.setString(1, this.containerConfig.containerName);
return findNodesCount.executeQuery();
}
@@ -1046,14 +1143,14 @@
dbConnection.prepareStatement("DELETE FROM JCR_SVALUE WHERE PROPERTY_ID
IN (SELECT ID FROM JCR_SITEM"
+ " WHERE CONTAINER_NAME = ? AND PARENT_ID=? AND (NAME =
'[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'))");
- removeValuesStatement.setString(1, containerName);
+ removeValuesStatement.setString(1, containerConfig.containerName);
removeValuesStatement.setString(2, getInternalId(nodeIdentifier));
removeItemsStatement =
dbConnection.prepareStatement("DELETE FROM JCR_SITEM WHERE
CONTAINER_NAME = ? AND PARENT_ID=? AND"
+ " (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep'
OR"
+ " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
- removeItemsStatement.setString(1, containerName);
+ removeItemsStatement.setString(1, containerConfig.containerName);
removeItemsStatement.setString(2, getInternalId(nodeIdentifier));
removeValuesStatement.executeUpdate();
@@ -1098,7 +1195,7 @@
}
findMaxPropertyVersions.setString(1, getInternalId(parentId));
- findMaxPropertyVersions.setString(2, containerName);
+ findMaxPropertyVersions.setString(2, containerConfig.containerName);
findMaxPropertyVersions.setString(3, name);
findMaxPropertyVersions.setInt(4, index);
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SybaseConnectionFactory.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SybaseConnectionFactory.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SybaseConnectionFactory.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
@@ -41,64 +42,20 @@
/**
* SybaseConnectionFactory constructor.
- *
- * @param dataSource
- * - DataSource
- * @param dbDriver
- * - JDBC Driver
- * @param dbUrl
- * - JDBC URL
- * @param dbUserName
- * - database username
- * @param dbPassword
- * - database user password
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- * @throws RepositoryException
- * if error eccurs
*/
- public SybaseConnectionFactory(String dbDriver, String dbUrl, String dbUserName,
String dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ public SybaseConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
{
- super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ super(containerConfig);
}
/**
* SybaseConnectionFactory constructor.
- *
- * @param dataSource
- * - DataSource
- * @param containerName
- * - Container name (see configuration)
- * @param multiDb
- * - multidatabase state flag
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
*/
- public SybaseConnectionFactory(DataSource dbDataSource, String containerName, boolean
multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ public SybaseConnectionFactory(DataSource dbDataSource, JDBCDataContainerConfig
containerConfig)
{
- super(dbDataSource, containerName, multiDb, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbDataSource, containerConfig);
}
-
+
/**
* {@inheritDoc}
*/
@@ -107,15 +64,12 @@
{
try
{
-
- if (multiDb)
+ if (this.containerConfig.dbStructureType.isSimpleTable())
{
- return new SybaseMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new SybaseMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
- return new SybaseSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return new SybaseSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
catch (SQLException e)
@@ -131,5 +85,5 @@
public boolean isReindexingSupport()
{
return true;
- }
+ }
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SybaseMultiDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SybaseMultiDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SybaseMultiDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -16,12 +16,10 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.SybaseJDBCConnectionHelper.EmptyResultSet;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
import org.exoplatform.services.jcr.util.IdGenerator;
-import java.io.File;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -73,11 +71,18 @@
protected PreparedStatement countNodesInTemporaryTable;
- public SybaseMultiDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ /**
+ * @param dbConnection
+ * JDBC connection, should be opened before
+ * @param readOnly
+ * boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerConfig
+ * Workspace Storage Container configuration
+ */
+ public SybaseMultiDbJDBCConnection(Connection dbConnection, boolean readOnly,
JDBCDataContainerConfig containerConfig)
throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -116,25 +121,24 @@
super.prepareQueries();
SELECT_LIMIT_OFFSET_NODES_INTO_TEMPORARY_TABLE =
- "select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_INDEX,
I.N_ORDER_NUM into "
- + SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME
- + " from JCR_MITEM I (index JCR_PK_MITEM) where I.I_CLASS=1
AND I.ID > ? order by I.ID ASC";
+ "select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_INDEX, I.N_ORDER_NUM into
"
+ + SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME + " from " +
JCR_ITEM
+ + " I (index "+JCR_PK_ITEM+") where I.I_CLASS=1 AND I.ID >
? order by I.ID ASC";
COUNT_NODES_IN_TEMPORARY_TABLE = "select count(*) from " +
SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME;
SELECT_LIMIT_NODES_FROM_TEMPORARY_TABLE =
- "select * into " + SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME
+ " from "
- + SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME + " order by
"
- + SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME + ".ID
DESC";
+ "select * into " + SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME +
" from "
+ + SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME + " order by "
+ + SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME + ".ID DESC";
FIND_NODES_AND_PROPERTIES =
- "select " + SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME
- + ".*, P.ID AS P_ID, P.NAME AS P_NAME, P.VERSION AS
P_VERSION, P.P_TYPE, P.P_MULTIVALUED,"
- + " V.DATA, V.ORDER_NUM, V.STORAGE_DESC from JCR_MVALUE V,
JCR_MITEM P, "
- + SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME + " where
P.PARENT_ID = "
- + SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME
- + ".ID and P.I_CLASS=2 and V.PROPERTY_ID=P.ID "
- + "order by " +
SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME + ".ID";
+ "select " + SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME
+ + ".*, P.ID AS P_ID, P.NAME AS P_NAME, P.VERSION AS P_VERSION, P.P_TYPE,
P.P_MULTIVALUED,"
+ + " V.DATA, V.ORDER_NUM, V.STORAGE_DESC from " + JCR_VALUE + "
V, " + JCR_ITEM + " P, "
+ + SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME + " where P.PARENT_ID =
"
+ + SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME + ".ID and P.I_CLASS=2
and V.PROPERTY_ID=P.ID "
+ + "order by " + SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME +
".ID";
DELETE_TEMPORARY_TABLE_A = "drop table " +
SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME;
@@ -161,17 +165,17 @@
}
selectLimitOffsetNodesIntoTemporaryTable =
-
dbConnection.prepareStatement(SELECT_LIMIT_OFFSET_NODES_INTO_TEMPORARY_TABLE.replaceAll(
- SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME,
tempTableAName));
+
dbConnection.prepareStatement(SELECT_LIMIT_OFFSET_NODES_INTO_TEMPORARY_TABLE.replaceAll(
+ SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME, tempTableAName));
countNodesInTemporaryTable =
-
dbConnection.prepareStatement(COUNT_NODES_IN_TEMPORARY_TABLE.replaceAll(
- SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME,
tempTableAName));
+ dbConnection.prepareStatement(COUNT_NODES_IN_TEMPORARY_TABLE.replaceAll(
+ SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME, tempTableAName));
selectLimitNodesInTemporaryTable =
-
dbConnection.prepareStatement(SELECT_LIMIT_NODES_FROM_TEMPORARY_TABLE.replaceAll(
- SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME,
tempTableAName).replaceAll(
- SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME,
tempTableBName));
+
dbConnection.prepareStatement(SELECT_LIMIT_NODES_FROM_TEMPORARY_TABLE.replaceAll(
+ SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME, tempTableAName).replaceAll(
+ SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME, tempTableBName));
if (findNodesAndProperties != null)
{
@@ -179,16 +183,16 @@
}
findNodesAndProperties =
- dbConnection.prepareStatement(FIND_NODES_AND_PROPERTIES.replaceAll(
- SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME,
tempTableBName));
+ dbConnection.prepareStatement(FIND_NODES_AND_PROPERTIES.replaceAll(
+ SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME, tempTableBName));
deleteTemporaryTableA =
- dbConnection.prepareStatement(DELETE_TEMPORARY_TABLE_A.replaceAll(
- SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME,
tempTableAName));
+ dbConnection.prepareStatement(DELETE_TEMPORARY_TABLE_A.replaceAll(
+ SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME, tempTableAName));
deleteTemporaryTableB =
- dbConnection.prepareStatement(DELETE_TEMPORARY_TABLE_B.replaceAll(
- SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME,
tempTableBName));
+ dbConnection.prepareStatement(DELETE_TEMPORARY_TABLE_B.replaceAll(
+ SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME, tempTableBName));
selectLimitOffsetNodesIntoTemporaryTable.setMaxRows(limit + offset);
selectLimitOffsetNodesIntoTemporaryTable.setString(1, lastNodeId);
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SybaseSingleDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SybaseSingleDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SybaseSingleDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -16,12 +16,10 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.SybaseJDBCConnectionHelper.EmptyResultSet;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
import org.exoplatform.services.jcr.util.IdGenerator;
-import java.io.File;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -73,11 +71,18 @@
protected PreparedStatement countNodesInTemporaryTable;
- public SybaseSingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory,
- FileCleaner swapCleaner) throws SQLException
+ /**
+ * @param dbConnection
+ * JDBC connection, should be opened before
+ * @param readOnly
+ * boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerConfig
+ * Workspace Storage Container configuration
+ */
+ public SybaseSingleDbJDBCConnection(Connection dbConnection, boolean readOnly,
+ JDBCDataContainerConfig containerConfig) throws SQLException
{
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerConfig);
}
/**
@@ -123,18 +128,18 @@
COUNT_NODES_IN_TEMPORARY_TABLE = "select count(*) from " +
SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME;
SELECT_LIMIT_NODES_FROM_TEMPORARY_TABLE =
- "select * into " + SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME
+ " from "
- + SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME + " order by
"
- + SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME + ".ID
DESC";
+ "select * into " + SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME +
" from "
+ + SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME + " order by "
+ + SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME + ".ID DESC";
FIND_NODES_AND_PROPERTIES =
- "select " + SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME
- + ".*, P.ID AS P_ID, P.NAME AS P_NAME, P.VERSION AS
P_VERSION, P.P_TYPE, P.P_MULTIVALUED,"
- + " V.DATA, V.ORDER_NUM, V.STORAGE_DESC from JCR_SVALUE V,
JCR_SITEM P, "
- + SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME + " where
P.PARENT_ID = "
- + SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME
- + ".ID and P.I_CLASS=2 and P.CONTAINER_NAME=? and
V.PROPERTY_ID=P.ID "
- + "order by " +
SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME + ".ID";
+ "select " + SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME
+ + ".*, P.ID AS P_ID, P.NAME AS P_NAME, P.VERSION AS P_VERSION, P.P_TYPE,
P.P_MULTIVALUED,"
+ + " V.DATA, V.ORDER_NUM, V.STORAGE_DESC from JCR_SVALUE V, JCR_SITEM P,
"
+ + SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME + " where P.PARENT_ID =
"
+ + SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME
+ + ".ID and P.I_CLASS=2 and P.CONTAINER_NAME=? and V.PROPERTY_ID=P.ID
" + "order by "
+ + SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME + ".ID";
DELETE_TEMPORARY_TABLE_A = "drop table " +
SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME;
@@ -161,17 +166,17 @@
}
selectLimitOffsetNodesIntoTemporaryTable =
-
dbConnection.prepareStatement(SELECT_LIMIT_OFFSET_NODES_INTO_TEMPORARY_TABLE.replaceAll(
- SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME,
tempTableAName));
+
dbConnection.prepareStatement(SELECT_LIMIT_OFFSET_NODES_INTO_TEMPORARY_TABLE.replaceAll(
+ SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME, tempTableAName));
countNodesInTemporaryTable =
-
dbConnection.prepareStatement(COUNT_NODES_IN_TEMPORARY_TABLE.replaceAll(
- SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME,
tempTableAName));
+ dbConnection.prepareStatement(COUNT_NODES_IN_TEMPORARY_TABLE.replaceAll(
+ SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME, tempTableAName));
selectLimitNodesInTemporaryTable =
-
dbConnection.prepareStatement(SELECT_LIMIT_NODES_FROM_TEMPORARY_TABLE.replaceAll(
- SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME,
tempTableAName).replaceAll(
- SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME,
tempTableBName));
+
dbConnection.prepareStatement(SELECT_LIMIT_NODES_FROM_TEMPORARY_TABLE.replaceAll(
+ SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME, tempTableAName).replaceAll(
+ SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME, tempTableBName));
if (findNodesAndProperties != null)
{
@@ -179,20 +184,19 @@
}
findNodesAndProperties =
- dbConnection.prepareStatement(FIND_NODES_AND_PROPERTIES.replaceAll(
- SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME,
tempTableBName));
+ dbConnection.prepareStatement(FIND_NODES_AND_PROPERTIES.replaceAll(
+ SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME, tempTableBName));
deleteTemporaryTableA =
- dbConnection.prepareStatement(DELETE_TEMPORARY_TABLE_A.replaceAll(
- SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME,
tempTableAName));
+ dbConnection.prepareStatement(DELETE_TEMPORARY_TABLE_A.replaceAll(
+ SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME, tempTableAName));
deleteTemporaryTableB =
- dbConnection.prepareStatement(DELETE_TEMPORARY_TABLE_B.replaceAll(
- SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME,
tempTableBName));
+ dbConnection.prepareStatement(DELETE_TEMPORARY_TABLE_B.replaceAll(
+ SybaseJDBCConnectionHelper.TEMP_B_TABLE_NAME, tempTableBName));
-
selectLimitOffsetNodesIntoTemporaryTable.setMaxRows(limit + offset);
- selectLimitOffsetNodesIntoTemporaryTable.setString(1, containerName);
+ selectLimitOffsetNodesIntoTemporaryTable.setString(1,
this.containerConfig.containerName);
selectLimitOffsetNodesIntoTemporaryTable.setString(2,
getInternalId(lastNodeId));
selectLimitOffsetNodesIntoTemporaryTable.execute();
@@ -226,7 +230,7 @@
tempTableBCreated = true;
- findNodesAndProperties.setString(1, containerName);
+ findNodesAndProperties.setString(1, this.containerConfig.containerName);
return findNodesAndProperties.executeQuery();
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -22,9 +22,11 @@
import org.exoplatform.commons.utils.PrivilegedFileHelper;
import org.exoplatform.commons.utils.SecurityHelper;
import org.exoplatform.services.database.utils.JDBCUtils;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;
@@ -66,7 +68,7 @@
protected final Connection connection;
- protected final String containerName;
+ protected final JDBCDataContainerConfig containerConfig;
protected final String script;
@@ -86,11 +88,11 @@
protected final Pattern dbTriggerNamePattern;
- public DBInitializer(String containerName, Connection connection, String scriptPath)
throws IOException
+ public DBInitializer(Connection connection, JDBCDataContainerConfig containerConfig)
throws IOException
{
this.connection = connection;
- this.containerName = containerName;
- this.script =
IOUtil.getStreamContentAsString(PrivilegedFileHelper.getResourceAsStream(scriptPath));
+ this.containerConfig = containerConfig;
+ this.script = prepareScripts();
this.creatTablePattern = Pattern.compile(SQL_CREATETABLE,
Pattern.CASE_INSENSITIVE);
this.creatViewPattern = Pattern.compile(SQL_CREATEVIEW, Pattern.CASE_INSENSITIVE);
this.dbObjectNamePattern = Pattern.compile(SQL_OBJECTNAME,
Pattern.CASE_INSENSITIVE);
@@ -101,6 +103,11 @@
this.dbTriggerNamePattern = Pattern.compile(SQL_TRIGGERNAME,
Pattern.CASE_INSENSITIVE);
}
+ protected String prepareScripts() throws IOException
+ {
+ return
IOUtil.getStreamContentAsString(PrivilegedFileHelper.getResourceAsStream(containerConfig.initScriptPath));
+ }
+
protected boolean isTableExists(final Connection conn, final String tableName) throws
SQLException
{
return SecurityHelper.doPrivilegedAction(new PrivilegedAction<Boolean>()
@@ -284,7 +291,7 @@
}
postInit(connection);
- LOG.info("DB schema of DataSource: '" + containerName +
"' initialized succesfully");
+ LOG.info("DB schema of DataSource: '" +
containerConfig.containerName + "' initialized succesfully");
}
catch (SQLException e)
{
@@ -292,9 +299,8 @@
{
LOG.error("Problem creating database structure.", e);
}
- LOG
- .warn("Some tables were created and not rolled back. Please make sure to
drop them manually in datasource : '"
- + containerName + "'");
+ LOG.warn("Some tables were created and not rolled back. Please make sure to
drop them manually in datasource : '"
+ + containerConfig.containerName + "'");
boolean isAlreadyCreated = false;
try
@@ -308,14 +314,14 @@
if (isAlreadyCreated)
{
- LOG.warn("Could not create db schema of DataSource: '" +
containerName + "'. Reason: Objects form " + sql
- + " already exists");
+ LOG.warn("Could not create db schema of DataSource: '" +
containerConfig.containerName
+ + "'. Reason: Objects form " + sql + " already
exists");
}
else
{
String msg =
- "Could not create db schema of DataSource: '" +
containerName + "'. Reason: " + e.getMessage() + "; "
- + JDBCUtils.getFullMessage(e) + ". Last command: " + sql;
+ "Could not create db schema of DataSource: '" +
containerConfig.containerName + "'. Reason: "
+ + e.getMessage() + "; " + JDBCUtils.getFullMessage(e) +
". Last command: " + sql;
throw new DBInitializerException(msg, e);
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializerHelper.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializerHelper.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializerHelper.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -22,6 +22,7 @@
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -121,19 +122,59 @@
/**
* Initialization script for root node.
+ *
+ */
+ public static String getRootNodeInitializeScript(JDBCDataContainerConfig
containerConfig)
+ {
+ // no ContainerNamer required
+ boolean simpleTable = containerConfig.dbStructureType.isSimpleTable();
+
+ return "insert into JCR_" + getTableSuffix(containerConfig) + "(ID,
PARENT_ID, NAME, "
+ + (simpleTable ? "" : "CONTAINER_NAME, ") + "VERSION,
I_CLASS, I_INDEX, N_ORDER_NUM)" + " VALUES('"
+ + Constants.ROOT_PARENT_UUID + "', '" +
Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_NAME
+ + "', " + (simpleTable ? "" : "'" +
Constants.ROOT_PARENT_CONAINER_NAME + "', ") + "0, 0, 0, 0)";
+ }
+
+ /**
+ * Initialization script for root node.
*
* @param multiDb
* indicates if we have multi-db configuration or not
* @return SQL script
*/
+ @Deprecated
public static String getRootNodeInitializeScript(boolean multiDb)
{
- return "insert into JCR_" + (multiDb ? "M" : "S") +
"ITEM(ID, PARENT_ID, NAME, " + (multiDb ? "" : "CONTAINER_NAME,
")
- + "VERSION, I_CLASS, I_INDEX, N_ORDER_NUM)" + "
VALUES('"
+ return "insert into JCR_" + (multiDb ? "M" : "S") +
"ITEM(ID, PARENT_ID, NAME, "
+ + (multiDb ? "" : "CONTAINER_NAME, ") + "VERSION,
I_CLASS, I_INDEX, N_ORDER_NUM)" + " VALUES('"
+ Constants.ROOT_PARENT_UUID + "', '" +
Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_NAME
+ "', " + (multiDb ? "" : "'" +
Constants.ROOT_PARENT_CONAINER_NAME + "', ") + "0, 0, 0, 0)";
}
+ public static String getTableSuffix(JDBCDataContainerConfig containerConfig)
+ {
+ String tableSuffix = "";
+ switch (containerConfig.dbStructureType)
+ {
+ case MULTI :
+ tableSuffix = "MITEM";
+ break;
+ case SINGLE :
+ tableSuffix = "SITEM";
+ break;
+ case ISOLATED :
+ tableSuffix = "I" + containerConfig.dbTableSuffix;
+ break;
+ }
+ return tableSuffix;
+ }
+
+ public static String getScriptAsString(String dbDialect, boolean multiDb) throws
IOException
+ {
+ String scriptsPath = DBInitializerHelper.scriptPath(dbDialect, multiDb);
+ return
IOUtil.getStreamContentAsString(PrivilegedFileHelper.getResourceAsStream(scriptsPath));
+ }
+
/**
* Get script for creating object (index, etc...)
* @throws RepositoryConfigurationException
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSVNodeDataOptimization.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSVNodeDataOptimization.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSVNodeDataOptimization.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -19,10 +19,13 @@
import org.exoplatform.services.jcr.JcrImplBaseTest;
import org.exoplatform.services.jcr.config.ContainerEntry;
import org.exoplatform.services.jcr.config.QueryHandlerEntry;
+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.config.WorkspaceInitializerEntry;
import org.exoplatform.services.jcr.datamodel.NodeData;
+import
org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig.DatabaseStructureType;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import java.io.File;
import java.io.FileOutputStream;
@@ -42,15 +45,14 @@
* @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex
Reshetnyak</a>
* @version $Id$
*/
-public class TestSVNodeDataOptimization
- extends JcrImplBaseTest
+public class TestSVNodeDataOptimization extends JcrImplBaseTest
{
-
+
@Override
public void setUp() throws Exception
{
super.setUp();
- SessionImpl ses = (SessionImpl) repository.login(credentials, "ws1");
+ SessionImpl ses = (SessionImpl)repository.login(credentials, "ws1");
if (ses != null)
{
try
@@ -86,7 +88,7 @@
@Override
protected void tearDown() throws Exception
{
- SessionImpl ses = (SessionImpl) repository.login(credentials, "ws1");
+ SessionImpl ses = (SessionImpl)repository.login(credentials, "ws1");
if (ses != null)
{
try
@@ -124,7 +126,7 @@
{
//ADD content
- SessionImpl ses = (SessionImpl) repository.login(credentials, "ws1");
+ SessionImpl ses = (SessionImpl)repository.login(credentials, "ws1");
//Add node with sub name sibling
Node nodeSNS = ses.getRootNode().addNode("node_with_sns");
@@ -150,12 +152,12 @@
// restore to ws1_restored
WorkspaceEntry ws1_restore =
- makeWorkspaceEntry("ws1_restored", isMultiDB(session) ?
"jdbcjcr2export3" : "jdbcjcr", backup, ses);
+ makeWorkspaceEntry("ws1_restored", isMultiDB(session) ?
"jdbcjcr2export3" : "jdbcjcr", backup, ses);
repository.configWorkspace(ws1_restore);
repository.createWorkspace(ws1_restore.getName());
// check
- SessionImpl backupSession = (SessionImpl) repository.login(credentials,
"ws1_restored");
+ SessionImpl backupSession = (SessionImpl)repository.login(credentials,
"ws1_restored");
assertNotNull(backupSession);
@@ -164,8 +166,8 @@
private void checkEquals(SessionImpl expected, SessionImpl actual) throws Exception
{
- NodeImpl srcNode = (NodeImpl) expected.getRootNode();
- NodeImpl destNode = (NodeImpl) actual.getRootNode();
+ NodeImpl srcNode = (NodeImpl)expected.getRootNode();
+ NodeImpl destNode = (NodeImpl)actual.getRootNode();
checkNodeEquals(srcNode, destNode);
}
@@ -174,7 +176,7 @@
{
assertTrue(dest.equals(src));
assertEquals(src.getIndex(), dest.getIndex());
- assertEquals(((NodeData) src.getData()).getOrderNumber(), ((NodeData)
dest.getData()).getOrderNumber());
+ assertEquals(((NodeData)src.getData()).getOrderNumber(),
((NodeData)dest.getData()).getOrderNumber());
NodeIterator srcIterator = src.getNodes();
NodeIterator destIterator = dest.getNodes();
@@ -182,18 +184,19 @@
assertEquals(srcIterator.getSize(), destIterator.getSize());
while (srcIterator.hasNext())
- checkNodeEquals((NodeImpl) srcIterator.nextNode(), (NodeImpl)
destIterator.nextNode());
+ {
+ checkNodeEquals((NodeImpl)srcIterator.nextNode(),
(NodeImpl)destIterator.nextNode());
+ }
}
private WorkspaceEntry makeWorkspaceEntry(String name, String sourceName, File
sysViewFile, SessionImpl ses)
{
- WorkspaceEntry ws1e = (WorkspaceEntry)
ses.getContainer().getComponentInstanceOfType(WorkspaceEntry.class);
+ WorkspaceEntry ws1e =
(WorkspaceEntry)ses.getContainer().getComponentInstanceOfType(WorkspaceEntry.class);
WorkspaceEntry ws1back = new WorkspaceEntry();
ws1back.setName(name);
- ws1back.setUniqueName(((RepositoryImpl) ses.getRepository()).getName() +
"_" + ws1back.getName());
+ ws1back.setUniqueName(((RepositoryImpl)ses.getRepository()).getName() +
"_" + ws1back.getName());
-
ws1back.setAccessManager(ws1e.getAccessManager());
ws1back.setCache(ws1e.getCache());
ws1back.setContainer(ws1e.getContainer());
@@ -205,7 +208,7 @@
List<SimpleParameterEntry> wieParams = new
ArrayList<SimpleParameterEntry>();
wieParams
- .add(new
SimpleParameterEntry(SysViewWorkspaceInitializer.RESTORE_PATH_PARAMETER,
sysViewFile.getPath()));
+ .add(new
SimpleParameterEntry(SysViewWorkspaceInitializer.RESTORE_PATH_PARAMETER,
sysViewFile.getPath()));
wiEntry.setParameters(wieParams);
@@ -215,28 +218,34 @@
ArrayList qParams = new ArrayList();
qParams.add(new SimpleParameterEntry("indexDir", "target" +
File.separator + name));
QueryHandlerEntry qEntry =
- new
QueryHandlerEntry("org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex",
qParams);
+ new
QueryHandlerEntry("org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex",
qParams);
ws1back.setQueryHandler(qEntry);
ArrayList params = new ArrayList();
for (Iterator i = ws1back.getContainer().getParameters().iterator(); i.hasNext();)
{
- SimpleParameterEntry p = (SimpleParameterEntry) i.next();
+ SimpleParameterEntry p = (SimpleParameterEntry)i.next();
SimpleParameterEntry newp = new SimpleParameterEntry(p.getName(),
p.getValue());
if (isMultiDB(ses) && newp.getName().equals("source-name"))
+ {
newp.setValue(sourceName);
+ }
else if (newp.getName().equals("swap-directory"))
+ {
newp.setValue("target/temp/swap/" + name);
+ }
else if (isMultiDB(ses) && newp.getName().equals("dialect"))
+ {
newp.setValue("hsqldb");
+ }
params.add(newp);
}
ContainerEntry ce =
- new
ContainerEntry("org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer",
params);
+ new
ContainerEntry("org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer",
params);
ws1back.setContainer(ce);
return ws1back;
@@ -244,19 +253,19 @@
private boolean isMultiDB(SessionImpl session)
{
- WorkspaceEntry ws1e = (WorkspaceEntry)
session.getContainer().getComponentInstanceOfType(WorkspaceEntry.class);
+ WorkspaceEntry ws1e =
(WorkspaceEntry)session.getContainer().getComponentInstanceOfType(WorkspaceEntry.class);
- for (Iterator i = ws1e.getContainer().getParameters().iterator(); i.hasNext();)
+ try
{
- SimpleParameterEntry p = (SimpleParameterEntry) i.next();
- SimpleParameterEntry newp = new SimpleParameterEntry(p.getName(),
p.getValue());
-
- if (newp.getName().equals("multi-db"))
- return Boolean.valueOf(newp.getValue());
+ DatabaseStructureType databaseType =
JDBCWorkspaceDataContainer.getDatabaseType(ws1e);
+ return !databaseType.isSingleDatabase();
}
+ catch (RepositoryConfigurationException e)
+ {
+ throw new RuntimeException("Can not get property 'multi-db' in
configuration on workspace '" + ws1e.getName()
+ + "'");
+ }
- throw new RuntimeException("Can not get property 'multi-db' in
configuration on workspace '" + ws1e.getName()
- + "'");
}
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -17,6 +17,8 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.db;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCConnectionTestBase;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
+import
org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig.DatabaseStructureType;
import org.exoplatform.services.jcr.impl.storage.jdbc.init.StorageDBInitializer;
import java.sql.SQLException;
@@ -36,9 +38,14 @@
private void setUp(String scriptPath, boolean multiDB) throws Exception
{
super.setUp();
- new StorageDBInitializer("ws3", getJNDIConnection(), scriptPath,
multiDB).init();
+ JDBCDataContainerConfig containerConfig = new JDBCDataContainerConfig();
+ containerConfig.containerName = "ws3";
+ containerConfig.initScriptPath = scriptPath;
+ containerConfig.dbStructureType = multiDB ? DatabaseStructureType.MULTI :
DatabaseStructureType.SINGLE;
+ containerConfig.multiDb = multiDB;
+ new StorageDBInitializer(getJNDIConnection(), containerConfig).init();
}
-
+
@Override
public void setUp() throws Exception
{
@@ -56,7 +63,12 @@
+ "('0xce',16,'B','testConn2')");
st.executeUpdate("insert into JCR_MREF values" +
"('D','A',2)");
st.executeUpdate("insert into JCR_MREF values" +
"('E','B',2)");
- jdbcConn = new MultiDbJDBCConnection(getJNDIConnection(), false,
"ws3", null, 10, null, null);
+ JDBCDataContainerConfig jdbcDataContainerConfig = new
JDBCDataContainerConfig();
+ jdbcDataContainerConfig.containerName = "ws3";
+ jdbcDataContainerConfig.maxBufferSize = 10;
+ jdbcDataContainerConfig.dbStructureType = DatabaseStructureType.MULTI;
+ jdbcDataContainerConfig.multiDb = true;
+ jdbcConn = new MultiDbJDBCConnection(getJNDIConnection(), false,
jdbcDataContainerConfig);
tableType = "M";
st.close();
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -17,6 +17,8 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.db;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCConnectionTestBase;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
+import
org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig.DatabaseStructureType;
import org.exoplatform.services.jcr.impl.storage.jdbc.init.StorageDBInitializer;
import java.sql.SQLException;
@@ -36,9 +38,14 @@
private void setUp(String scriptPath, boolean multiDB) throws Exception
{
super.setUp();
- new StorageDBInitializer("ws3", getJNDIConnection(), scriptPath,
multiDB).init();
+ JDBCDataContainerConfig containerConfig = new JDBCDataContainerConfig();
+ containerConfig.containerName = "ws3";
+ containerConfig.initScriptPath = scriptPath;
+ containerConfig.dbStructureType = multiDB ? DatabaseStructureType.MULTI :
DatabaseStructureType.SINGLE;
+ containerConfig.multiDb = multiDB;
+ new StorageDBInitializer(getJNDIConnection(), containerConfig).init();
}
-
+
@Override
public void setUp() throws Exception
{
@@ -57,7 +64,12 @@
st.executeUpdate("insert into JCR_SREF values" +
"('D','A',2)");
st.executeUpdate("insert into JCR_SREF values" +
"('E','B',2)");
st.close();
- jdbcConn = new SingleDbJDBCConnection(getJNDIConnection(), false,
"ws3", null, 10, null, null);
+ JDBCDataContainerConfig jdbcDataContainerConfig = new
JDBCDataContainerConfig();
+ jdbcDataContainerConfig.containerName = "ws3";
+ jdbcDataContainerConfig.maxBufferSize = 10;
+ jdbcDataContainerConfig.dbStructureType = DatabaseStructureType.SINGLE;
+ jdbcDataContainerConfig.multiDb = false;
+ jdbcConn = new SingleDbJDBCConnection(getJNDIConnection(), false,
jdbcDataContainerConfig);
tableType = "S";
}
catch (SQLException se)
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/export/ExportWorkspaceSystemViewTest.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/export/ExportWorkspaceSystemViewTest.java 2012-03-06
15:56:19 UTC (rev 5824)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/export/ExportWorkspaceSystemViewTest.java 2012-03-07
09:01:33 UTC (rev 5825)
@@ -21,12 +21,15 @@
import org.exoplatform.services.jcr.config.ContainerEntry;
import org.exoplatform.services.jcr.config.QueryHandlerEntry;
import org.exoplatform.services.jcr.config.QueryHandlerParams;
+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.config.WorkspaceInitializerEntry;
import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
import org.exoplatform.services.jcr.impl.core.SysViewWorkspaceInitializer;
+import
org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig.DatabaseStructureType;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.usecases.BaseUsecasesTest;
import java.io.File;
@@ -131,11 +134,17 @@
SimpleParameterEntry newp = new SimpleParameterEntry(p.getName(),
p.getValue());
if (isMultiDB(session) &&
newp.getName().equals("source-name"))
+ {
newp.setValue(sourceName);
+ }
else if (newp.getName().equals("swap-directory"))
+ {
newp.setValue("target/temp/swap/" + name);
+ }
else if (isMultiDB(session) &&
newp.getName().equals("dialect"))
+ {
newp.setValue("hsqldb");
+ }
params.add(newp);
}
@@ -151,16 +160,16 @@
{
WorkspaceEntry ws1e =
(WorkspaceEntry)session.getContainer().getComponentInstanceOfType(WorkspaceEntry.class);
- for (Iterator i = ws1e.getContainer().getParameters().iterator(); i.hasNext();)
+ try
{
- SimpleParameterEntry p = (SimpleParameterEntry)i.next();
- SimpleParameterEntry newp = new SimpleParameterEntry(p.getName(),
p.getValue());
-
- if (newp.getName().equals("multi-db"))
- return Boolean.valueOf(newp.getValue());
+ DatabaseStructureType databaseType =
JDBCWorkspaceDataContainer.getDatabaseType(ws1e);
+ return !databaseType.isSingleDatabase();
}
+ catch (RepositoryConfigurationException e)
+ {
+ throw new RuntimeException("Can not get property 'multi-db' in
configuration on workspace '" + ws1e.getName()
+ + "'");
+ }
- throw new RuntimeException("Can not get property 'multi-db' in
configuration on workspace '" + ws1e.getName()
- + "'");
}
}
Added:
jcr/branches/1.15.x/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-ijdbc-jbc.xml
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-ijdbc-jbc.xml
(rev 0)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-ijdbc-jbc.xml 2012-03-07
09:01:33 UTC (rev 5825)
@@ -0,0 +1,504 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+-->
+<configuration
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.exoplatform.org/xml/ns/kernel_1_2.xsd
http://www.exoplatform.org/xml/ns/kernel_1_2.xsd"
+
xmlns="http://www.exoplatform.org/xml/ns/kernel_1_2.xsd">
+ <component>
+ <key>org.exoplatform.services.log.LogConfigurationInitializer</key>
+ <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
+ <init-params>
+ <value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedLog4JLogger</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.Log4JConfigurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>Log4J properties</description>
+ <property name="log4j.rootLogger" value="INFO, stdout,
file"/>
+
+ <property name="log4j.appender.stdout"
value="org.apache.log4j.ConsoleAppender"/>
+ <property name="log4j.appender.stdout.threshold"
value="DEBUG"/>
+
+ <property name="log4j.appender.stdout.layout"
value="org.apache.log4j.PatternLayout"/>
+ <property name="log4j.appender.stdout.layout.ConversionPattern"
+ value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L)
%n"/>
+
+ <property name="log4j.appender.file"
value="org.apache.log4j.FileAppender"/>
+ <property name="log4j.appender.file.File"
value="target/jcr.log"/>
+
+ <property name="log4j.appender.file.layout"
value="org.apache.log4j.PatternLayout"/>
+ <property name="log4j.appender.file.layout.ConversionPattern"
+ value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L)
%n"/>
+
+ <!-- property name="log4j.category.jcr.FileCleaner"
value="DEBUG"/ -->
+
+ <!-- property name="log4j.category.jcr.JDBCStorageConnection"
value="DEBUG"/>
+ <property name="log4j.category.jcr.NodeImpl"
value="DEBUG"/ -->
+
+ <!-- property name="log4j.category.jcr.WorkspaceStorageCacheImpl"
value="DEBUG"/ -->
+ <!-- property name="log4j.category.database.DBSchemaCreator"
value="DEBUG"/ -->
+ <!-- property name="log4j.category.jcr.WorkspaceDataReplicator"
value="DEBUG"/ -->
+
+ <!-- property name="log4j.category.jcr.WorkspaceStorageCacheImpl"
value="DEBUG"/ -->
+ <!-- property
name="log4j.category.jcr.WorkspacePersistentDataManager"
value="DEBUG"/ -->
+ <!-- property name="log4j.category.jcr.SessionDataManager"
value="DEBUG"/ -->
+ </properties-param>
+
+ <!-- value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedSimpleLog</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.SimpleLogConfigurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>SimpleLog properties</description>
+ <property name="org.apache.commons.logging.simplelog.defaultlog"
value="debug"/>
+ <property name="org.apache.commons.logging.simplelog.showdatetime"
value="true"/>
+ </properties-param -->
+
+ <!-- value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedJdk14Logger</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.Jdk14Configurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>jdk1.4 Logger properties</description>
+ <property name="handlers"
value="java.util.logging.ConsoleHandler"/>
+ <property name=".level" value="FINE"/>
+ <property name="java.util.logging.ConsoleHandler.level"
value="FINE"/>
+ </properties-param -->
+
+ </init-params>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.jcr.RepositoryService</key>
+ <type>org.exoplatform.services.jcr.impl.RepositoryServiceImpl</type>
+ <component-plugins>
+ <component-plugin>
+ <name>add.namespaces</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.jcr.impl.AddNamespacesPlugin</type>
+ <init-params>
+ <properties-param>
+ <name>namespaces</name>
+ <property name="test"
value="http://www.apache.org/jackrabbit/test"/>
+ <property name="exojcrtest"
value="http://www.exoplatform.org/jcr/test/1.0"/>
+ <property name="rma"
value="http://www.rma.com/jcr/"/>
+ <property name="metadata"
value="http://www.exoplatform.com/jcr/metadata/1.1/"/>
+ <property name="dc"
value="http://purl.org/dc/elements/1.1/"/>
+ <property name="publication"
value="http://www.exoplatform.com/jcr/publication/1.1/"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>add.nodeType</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.jcr.impl.AddNodeTypePlugin</type>
+ <init-params>
+ <values-param>
+ <name>autoCreatedInNewRepository</name>
+ <description>Node types configuration file</description>
+ <value>jar:/conf/test/nodetypes-tck.xml</value>
+ <value>jar:/conf/test/nodetypes-impl.xml</value>
+ <value>jar:/conf/test/nodetypes-usecase.xml</value>
+ <value>jar:/conf/test/nodetypes-config.xml</value>
+ <value>jar:/conf/test/nodetypes-config-extended.xml</value>
+ <value>jar:/conf/test/wcm-nodetypes.xml</value>
+ <value>jar:/conf/test/nodetypes-publication-config.xml</value>
+
<value>jar:/conf/test/publication-plugins-nodetypes-config.xml</value>
+ </values-param>
+
+ <values-param>
+ <name>testInitNodeTypesRepository</name>
+ <description>
+ Node types configuration file for repository with name
testInitNodeTypesRepository
+ </description>
+ <value>jar:/conf/test/nodetypes-test.xml</value>
+ </values-param>
+
+ <values-param>
+ <name>testInitNodeTypesRepositoryTest2</name>
+ <description>
+ Node types configuration file for repository with name
testInitNodeTypesRepositoryTest2
+ </description>
+ <value>jar:/conf/test/nodetypes-test2.xml</value>
+ </values-param>
+
+ <!--values-param>
+ <name>testInitNodeTypesRepositoryTest3</name>
+ <description>Node types from ext. Needed bacause core starup earlie than
ext</description>
+ <value>jar:/conf/test/nodetypes-test3_ext.xml</value>
+ </values-param-->
+
+ </init-params>
+ </component-plugin>
+ </component-plugins>
+ </component>
+
+ <component>
+
<key>org.exoplatform.services.jcr.config.RepositoryServiceConfiguration</key>
+
<type>org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl</type>
+ <init-params>
+ <value-param>
+ <name>conf-path</name>
+ <description>JCR configuration file</description>
+ <value>jar:/conf/standalone/test-jcr-config-ijdbc-jbc.xml</value>
+ </value-param>
+ <properties-param>
+ <name>working-conf</name>
+ <description>working-conf</description>
+ <property name="dialect" value="auto" />
+ <property name="source-name" value="jdbcjcr"/>
+ <property name="persister-class-name"
value="org.exoplatform.services.jcr.impl.config.JDBCConfigurationPersister"/>
+ </properties-param>
+ </init-params>
+ </component>
+
+ <component>
+
<type>org.exoplatform.services.organization.impl.mock.DummyOrganizationService</type>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.security.Authenticator</key>
+
<type>org.exoplatform.services.organization.auth.OrganizationAuthenticatorImpl</type>
+ </component>
+
+ <component>
+
<type>org.exoplatform.services.jcr.impl.ext.action.SessionActionCatalog</type>
+ </component>
+
+ <component>
+ <key>org.jboss.cache.transaction.TransactionManagerLookup</key>
+
<type>org.jboss.cache.transaction.JBossStandaloneJTAManagerLookup</type>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.transaction.TransactionService</key>
+
<type>org.exoplatform.services.transaction.jbosscache.JBossTransactionsService</type>
+ <init-params>
+ <value-param>
+ <name>timeout</name>
+ <value>3000</value>
+ </value-param>
+ </init-params>
+ </component>
+
+ <!-- component>
+ <key>org.exoplatform.services.transaction.TransactionService</key>
+
<type>org.exoplatform.services.transaction.impl.jotm.TransactionServiceJotmImpl</type>
+ <init-params>
+ <value-param>
+ <name>timeout</name>
+ <value>300</value>
+ </value-param>
+ </init-params>
+ </component -->
+
+ <external-component-plugins>
+
<target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="${all.driverClassName:org.hsqldb.jdbcDriver}"/>
+ <!-- MVCC configured to prevent possible deadlocks when a global Tx is
active -->
+ <property name="url"
value="${jdbcjcr.url:jdbc:hsqldb:file:target/temp/data/portal;hsqldb.tx=mvcc}"/>
+ <property name="username"
value="${jdbcjcr.username:sa}"/>
+ <property name="password"
value="${jdbcjcr.password:}"/>
+ <property name="maxActive" value="20" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcrtest</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jcrtest"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ <property name="maxActive" value="100" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcrdb2</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="${all.driverClassName:org.hsqldb.jdbcDriver}"/>
+ <property name="url"
value="${jdbcjcrdb2.url:jdbc:hsqldb:file:target/temp/data/portaldb2}"/>
+ <property name="username"
value="${jdbcjcrdb2.username:sa}"/>
+ <property name="password"
value="${jdbcjcrdb2.password:}"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcrtck</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="${all.driverClassName:org.hsqldb.jdbcDriver}"/>
+ <property name="url"
value="${jdbcjcrtck.url:jdbc:hsqldb:file:target/temp/data/portaltck}"/>
+ <property name="username"
value="${jdbcjcrtck.username:sa}"/>
+ <property name="password"
value="${jdbcjcrtck.password:}"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr2export1</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jdbcjcr2export1"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr2export2</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jdbcjcr2export2"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr2export3</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jdbcjcr2export3"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>testdbcleaner</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="${all.driverClassName:org.hsqldb.jdbcDriver}"/>
+ <property name="url"
value="${testdbcleaner.url:jdbc:hsqldb:file:target/temp/data/testdbcleaner}"/>
+ <property name="username"
value="${testdbcleaner.username:sa}"/>
+ <property name="password"
value="${testdbcleaner.password:}"/>
+ <property name="maxActive" value="20" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.jcr</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>repo</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.jcr.Repository</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+
<value>org.exoplatform.services.jcr.impl.jndi.BindableRepositoryFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="repositoryName" value="db1"/>
+ <!-- property name="containerConfig"
value="exo-configuration.xml"/ -->
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>rmi.jcr</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>rmirepository</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.jcr.Repository</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.exoplatform.services.jcr.rmi.RepositoryFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="url"
value="//localhost:9999/repository"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+
+
<remove-configuration>org.exoplatform.services.scheduler.JobSchedulerService</remove-configuration>
+ <!--<import>jar:/conf/database-configuration.hsql.xml</import> -->
+</configuration>
Added:
jcr/branches/1.15.x/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-ijdbc-jbc.xml
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-ijdbc-jbc.xml
(rev 0)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-ijdbc-jbc.xml 2012-03-07
09:01:33 UTC (rev 5825)
@@ -0,0 +1,627 @@
+<?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="db-structure-type"
value="isolated" />
+ <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" />
+ <property name="enabled"
value="${value-storage-enabled}" />
+ </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="${cache-enabled}"
+
class="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache">
+ <properties>
+ <property name="jbosscache-configuration"
value="conf/standalone/test-jbosscache-config.xml" />
+ <property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
+ </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.jbosscache.CacheableLockManagerImpl">
+ <properties>
+ <property name="time-out" value="15m" />
+ <property name="jbosscache-configuration"
value="conf/standalone/test-jbosscache-lock.xml" />
+ <property name="jbosscache-cl-cache.jdbc.table.name"
value="jcrlocks_db1_ws" />
+ <property name="jbosscache-cl-cache.jdbc.table.create"
value="true" />
+ <property name="jbosscache-cl-cache.jdbc.table.drop"
value="false" />
+ <property
name="jbosscache-cl-cache.jdbc.table.primarykey"
value="jcrlocks_db1_ws_pk" />
+ <property name="jbosscache-cl-cache.jdbc.fqn.column"
value="fqn" />
+ <property name="jbosscache-cl-cache.jdbc.node.column"
value="node" />
+ <property name="jbosscache-cl-cache.jdbc.parent.column"
value="parent" />
+ <property name="jbosscache-cl-cache.jdbc.datasource"
value="jdbcjcr" />
+ <property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
+ </properties>
+ </lock-manager>
+ </workspace>
+
+ <workspace name="ws1">
+ <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="db-structure-type"
value="isolated" />
+ <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" />
+ <property name="enabled"
value="${value-storage-enabled}" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <cache enabled="${cache-enabled}"
+
class="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache">
+ <properties>
+ <property name="jbosscache-configuration"
value="conf/standalone/test-jbosscache-config.xml" />
+ <property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
+ </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.jbosscache.CacheableLockManagerImpl">
+ <properties>
+ <property name="time-out" value="15m" />
+ <property name="jbosscache-configuration"
value="conf/standalone/test-jbosscache-lock.xml" />
+ <property name="jbosscache-cl-cache.jdbc.table.name"
value="jcrlocks_db1_ws1" />
+ <property name="jbosscache-cl-cache.jdbc.table.create"
value="true" />
+ <property name="jbosscache-cl-cache.jdbc.table.drop"
value="false" />
+ <property
name="jbosscache-cl-cache.jdbc.table.primarykey"
value="jcrlocks_db1_ws1_pk" />
+ <property name="jbosscache-cl-cache.jdbc.fqn.column"
value="fqn" />
+ <property name="jbosscache-cl-cache.jdbc.node.column"
value="node" />
+ <property name="jbosscache-cl-cache.jdbc.parent.column"
value="parent" />
+ <property name="jbosscache-cl-cache.jdbc.datasource"
value="jdbcjcr" />
+ <property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
+ </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="jdbcjcr"
/>
+ <property name="dialect" value="auto" />
+ <property name="db-structure-type"
value="isolated" />
+ <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" />
+ <property name="enabled"
value="${value-storage-enabled}" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <cache enabled="${cache-enabled}"
+
class="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache">
+ <properties>
+ <property name="jbosscache-configuration"
value="conf/standalone/test-jbosscache-config.xml" />
+ <property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
+ </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.jbosscache.CacheableLockManagerImpl">
+ <properties>
+ <property name="time-out" value="15m" />
+ <property name="jbosscache-configuration"
value="conf/standalone/test-jbosscache-lock.xml" />
+ <property name="jbosscache-cl-cache.jdbc.table.name"
value="jcrlocks_db1_ws2" />
+ <property name="jbosscache-cl-cache.jdbc.table.create"
value="true" />
+ <property name="jbosscache-cl-cache.jdbc.table.drop"
value="false" />
+ <property
name="jbosscache-cl-cache.jdbc.table.primarykey"
value="jcrlocks_db1_ws2_pk" />
+ <property name="jbosscache-cl-cache.jdbc.fqn.column"
value="fqn" />
+ <property name="jbosscache-cl-cache.jdbc.node.column"
value="node" />
+ <property name="jbosscache-cl-cache.jdbc.parent.column"
value="parent" />
+ <property name="jbosscache-cl-cache.jdbc.datasource"
value="jdbcjcr" />
+ <property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
+ </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="jdbcjcr"
/>
+ <property name="dialect" value="auto" />
+ <property name="db-structure-type"
value="isolated" />
+ <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" />
+ <property name="enabled"
value="${value-storage-enabled}" />
+ </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" />
+ <property name="enabled"
value="${value-storage-enabled}" />
+ </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="${cache-enabled}"
+
class="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache">
+ <properties>
+ <property name="jbosscache-configuration"
value="conf/standalone/test-jbosscache-config.xml" />
+ <property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
+ </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.jbosscache.CacheableLockManagerImpl">
+ <properties>
+ <property name="time-out" value="15m" />
+ <property name="jbosscache-configuration"
value="conf/standalone/test-jbosscache-lock.xml" />
+ <property name="jbosscache-cl-cache.jdbc.table.name"
value="jcrlocks_db1_ws3" />
+ <property name="jbosscache-cl-cache.jdbc.table.create"
value="true" />
+ <property name="jbosscache-cl-cache.jdbc.table.drop"
value="false" />
+ <property
name="jbosscache-cl-cache.jdbc.table.primarykey"
value="jcrlocks_db1_ws3_pk" />
+ <property name="jbosscache-cl-cache.jdbc.fqn.column"
value="fqn" />
+ <property name="jbosscache-cl-cache.jdbc.node.column"
value="node" />
+ <property name="jbosscache-cl-cache.jdbc.parent.column"
value="parent" />
+ <property name="jbosscache-cl-cache.jdbc.datasource"
value="jdbcjcr" />
+ <property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
+ </properties>
+ </lock-manager>
+ </workspace>
+ </workspaces>
+ </repository>
+
+ <repository name="db2" 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="db-structure-type"
value="isolated" />
+ <property name="max-buffer-size" value="200k"
/>
+ <property name="swap-directory"
value="target/temp/swap/wsdb2" />
+ </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/wsdb2" />
+ <property name="enabled"
value="${value-storage-enabled}" />
+ </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="*:/platform/administrators
read;*:/platform/administrators add_node;*:/platform/administrators
set_property;*:/platform/administrators remove" />
+ </properties>
+ </initializer>
+ <cache enabled="${cache-enabled}"
+
class="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache">
+ <properties>
+ <property name="jbosscache-configuration"
value="conf/standalone/test-jbosscache-config.xml" />
+ <property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
+ </properties>
+ </cache>
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir"
value="target/temp/index/db2/ws" />
+ </properties>
+ </query-handler>
+ <lock-manager
class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManagerImpl">
+ <properties>
+ <property name="time-out" value="15m" />
+ <property name="jbosscache-configuration"
value="conf/standalone/test-jbosscache-lock.xml" />
+ <property name="jbosscache-cl-cache.jdbc.table.name"
value="jcrlocks_db2_ws" />
+ <property name="jbosscache-cl-cache.jdbc.table.create"
value="true" />
+ <property name="jbosscache-cl-cache.jdbc.table.drop"
value="false" />
+ <property
name="jbosscache-cl-cache.jdbc.table.primarykey"
value="jcrlocks_db2_ws_pk" />
+ <property name="jbosscache-cl-cache.jdbc.fqn.column"
value="fqn" />
+ <property name="jbosscache-cl-cache.jdbc.node.column"
value="node" />
+ <property name="jbosscache-cl-cache.jdbc.parent.column"
value="parent" />
+ <property name="jbosscache-cl-cache.jdbc.datasource"
value="jdbcjcr" />
+ <property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
+ </properties>
+ </lock-manager>
+ </workspace>
+
+ <workspace name="ws1">
+ <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="db-structure-type"
value="isolated" />
+ <property name="max-buffer-size" value="200k"
/>
+ <property name="swap-directory"
value="target/temp/swap/ws1db2" />
+ </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/ws1db2" />
+ <property name="enabled"
value="${value-storage-enabled}" />
+ </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;any add_node;any set_property;any remove" />
+ </properties>
+ </initializer>
+ <cache enabled="${cache-enabled}"
+
class="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache">
+ <properties>
+ <property name="jbosscache-configuration"
value="conf/standalone/test-jbosscache-config.xml" />
+ <property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
+ </properties>
+ </cache>
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir"
value="target/temp/index/db2/ws1" />
+ </properties>
+ </query-handler>
+ <lock-manager
class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManagerImpl">
+ <properties>
+ <property name="time-out" value="15m" />
+ <property name="jbosscache-configuration"
value="conf/standalone/test-jbosscache-lock.xml" />
+ <property name="jbosscache-cl-cache.jdbc.table.name"
value="jcrlocks_db2_ws1" />
+ <property name="jbosscache-cl-cache.jdbc.table.create"
value="true" />
+ <property name="jbosscache-cl-cache.jdbc.table.drop"
value="false" />
+ <property
name="jbosscache-cl-cache.jdbc.table.primarykey"
value="jcrlocks_db2_ws1_pk" />
+ <property name="jbosscache-cl-cache.jdbc.fqn.column"
value="fqn" />
+ <property name="jbosscache-cl-cache.jdbc.node.column"
value="node" />
+ <property name="jbosscache-cl-cache.jdbc.parent.column"
value="parent" />
+ <property name="jbosscache-cl-cache.jdbc.datasource"
value="jdbcjcr" />
+ <property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
+ </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="jdbcjcr"
/>
+ <property name="dialect" value="auto" />
+ <property name="db-structure-type"
value="isolated" />
+ <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" />
+ <property name="enabled"
value="${value-storage-enabled}" />
+ </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="${cache-enabled}"
+
class="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache">
+ <properties>
+ <property name="jbosscache-configuration"
value="conf/standalone/test-jbosscache-config.xml" />
+ <property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
+ </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.jbosscache.CacheableLockManagerImpl">
+ <properties>
+ <property name="time-out" value="15m" />
+ <property name="jbosscache-configuration"
value="conf/standalone/test-jbosscache-lock.xml" />
+ <property name="jbosscache-cl-cache.jdbc.table.name"
value="jcrlocks_db1tck_ws" />
+ <property name="jbosscache-cl-cache.jdbc.table.create"
value="true" />
+ <property name="jbosscache-cl-cache.jdbc.table.drop"
value="false" />
+ <property
name="jbosscache-cl-cache.jdbc.table.primarykey"
value="jcrlocks_db1tck_ws_pk" />
+ <property name="jbosscache-cl-cache.jdbc.fqn.column"
value="fqn" />
+ <property name="jbosscache-cl-cache.jdbc.node.column"
value="node" />
+ <property name="jbosscache-cl-cache.jdbc.parent.column"
value="parent" />
+ <property name="jbosscache-cl-cache.jdbc.datasource"
value="jdbcjcr" />
+ <property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
+ </properties>
+ </lock-manager>
+ </workspace>
+
+ <workspace name="ws1">
+ <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="db-structure-type"
value="isolated" />
+ <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" />
+ <property name="enabled"
value="${value-storage-enabled}" />
+ </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="${cache-enabled}"
+
class="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache">
+ <properties>
+ <property name="jbosscache-configuration"
value="conf/standalone/test-jbosscache-config.xml" />
+ <property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
+ </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.jbosscache.CacheableLockManagerImpl">
+ <properties>
+ <property name="time-out" value="15m" />
+ <property name="jbosscache-configuration"
value="conf/standalone/test-jbosscache-lock.xml" />
+ <property name="jbosscache-cl-cache.jdbc.table.name"
value="jcrlocks_db1tck_ws1" />
+ <property name="jbosscache-cl-cache.jdbc.table.create"
value="true" />
+ <property name="jbosscache-cl-cache.jdbc.table.drop"
value="false" />
+ <property
name="jbosscache-cl-cache.jdbc.table.primarykey"
value="jcrlocks_db1tck_ws1_pk" />
+ <property name="jbosscache-cl-cache.jdbc.fqn.column"
value="fqn" />
+ <property name="jbosscache-cl-cache.jdbc.node.column"
value="node" />
+ <property name="jbosscache-cl-cache.jdbc.parent.column"
value="parent" />
+ <property name="jbosscache-cl-cache.jdbc.datasource"
value="jdbcjcr" />
+ <property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
+ </properties>
+ </lock-manager>
+ </workspace>
+
+ <workspace name="ws2">
+ <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="db-structure-type"
value="isolated" />
+ <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" />
+ <property name="enabled"
value="${value-storage-enabled}" />
+ </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="${cache-enabled}"
+
class="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache">
+ <properties>
+ <property name="jbosscache-configuration"
value="conf/standalone/test-jbosscache-config.xml" />
+ <property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
+ </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.jbosscache.CacheableLockManagerImpl">
+ <properties>
+ <property name="time-out" value="15m" />
+ <property name="jbosscache-configuration"
value="conf/standalone/test-jbosscache-lock.xml" />
+ <property name="jbosscache-cl-cache.jdbc.table.name"
value="jcrlocks_db1tck_ws2" />
+ <property name="jbosscache-cl-cache.jdbc.table.create"
value="true" />
+ <property name="jbosscache-cl-cache.jdbc.table.drop"
value="false" />
+ <property
name="jbosscache-cl-cache.jdbc.table.primarykey"
value="jcrlocks_db1tck_ws2_pk" />
+ <property name="jbosscache-cl-cache.jdbc.fqn.column"
value="fqn" />
+ <property name="jbosscache-cl-cache.jdbc.node.column"
value="node" />
+ <property name="jbosscache-cl-cache.jdbc.parent.column"
value="parent" />
+ <property name="jbosscache-cl-cache.jdbc.datasource"
value="jdbcjcr" />
+ <property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
+ </properties>
+ </lock-manager>
+ </workspace>
+ </workspaces>
+ </repository>
+ </repositories>
+</repository-service>