Author: tolusha
Date: 2012-03-14 09:28:03 -0400 (Wed, 14 Mar 2012)
New Revision: 5863
Removed:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JBCShareableLockTableHandler.java.orig
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java.orig
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.orig
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/db/OracleConnectionFactory.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/SingleDbJDBCConnection.java.orig
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/developer-notes.txt
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/clean/rdbms/DBCleanService.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DB2CleaningScipts.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScriptsFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/HSQLDBCleaningScipts.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/MySQLCleaningScipts.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/OracleCleaningScipts.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/SybaseCleaningScipts.java
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/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/MySQLConnectionFactory.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/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/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/MSSQLConnectionFactory.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/PostgreConnectionFactory.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/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/core/TestWorkspaceRestore.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
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingWorkspaceSameConfigRestore.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/RdbmsWorkspaceInitializer.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/usecase/TestBackupRestore.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config-backup.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml
jcr/branches/1.15.x/exo.jcr.component.ftp/src/test/resources/conf/standalone/test-jcr-config.xml
Log:
EXOJCR-1772: Adopt RDBMS backup/restore/clean
Modified: jcr/branches/1.15.x/exo.jcr.component.core/developer-notes.txt
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/developer-notes.txt 2012-03-14 09:31:09 UTC
(rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/developer-notes.txt 2012-03-14 13:28:03 UTC
(rev 5863)
@@ -15,4 +15,5 @@
* Removed BackupSchedulerException class
* EXOJCR-1728: Remove ReadOnly support for WorkspacePersistentDataManager
* Lucene 3.0
-* Isolated DB Concept (EXOJCR-1754)
\ No newline at end of file
+* Isolated DB Concept (EXOJCR-1754)
+* Not supported parameters driverClassName, url, username, password, sourceName in JDBC
workspace datacontainer
\ No newline at end of file
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-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/pom.xml 2012-03-14 13:28:03 UTC (rev 5863)
@@ -1018,3 +1018,4 @@
</profile>
</profiles>
</project>
+
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -189,8 +189,6 @@
{
SecurityHelper.validateSecurityPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
- boolean multiDb = getMultiDbParameter(wsEntry);
-
String dialect = resolveDialect(wsEntry);
boolean autoCommit = dialect.equalsIgnoreCase(DialectConstants.DB_DIALECT_SYBASE);
@@ -290,7 +288,7 @@
{
try
{
- return
Boolean.parseBoolean(wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.MULTIDB));
+ return JDBCWorkspaceDataContainer.getDatabaseType(wsEntry).isMultiDatabase();
}
catch (RepositoryConfigurationException e)
{
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DB2CleaningScipts.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DB2CleaningScipts.java 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DB2CleaningScipts.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -67,8 +67,8 @@
{
List<String> scripts = new ArrayList<String>();
- String constraintName = "JCR_FK_" + tablePrefix +
"ITEM_PAREN";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM DROP CONSTRAINT
" + constraintName);
+ String constraintName = "JCR_FK_" + itemTableSuffix +
"_PAREN";
+ scripts.add("ALTER TABLE " + itemTableName + " DROP CONSTRAINT
" + constraintName);
return scripts;
}
@@ -81,8 +81,8 @@
List<String> scripts = new ArrayList<String>();
String constraintName =
- "JCR_FK_" + tablePrefix + "ITEM_PAREN FOREIGN KEY(PARENT_ID)
REFERENCES JCR_" + tablePrefix + "ITEM(ID)";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM ADD CONSTRAINT
" + constraintName);
+ "JCR_FK_" + itemTableSuffix + "_PAREN FOREIGN KEY(PARENT_ID)
REFERENCES " + itemTableName + "(ID)";
+ scripts.add("ALTER TABLE " + itemTableName + " ADD CONSTRAINT "
+ constraintName);
return scripts;
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -18,8 +18,6 @@
*/
package org.exoplatform.services.jcr.impl.clean.rdbms.scripts;
-import org.exoplatform.commons.utils.IOUtil;
-import org.exoplatform.commons.utils.PrivilegedFileHelper;
import org.exoplatform.services.database.utils.JDBCUtils;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.RepositoryEntry;
@@ -28,7 +26,6 @@
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@@ -40,20 +37,32 @@
*/
public abstract class DBCleaningScripts
{
- protected final String tablePrefix;
+ protected String itemTableName;
+ protected String valueTableName;
+
+ protected String refTableName;
+
+ protected String itemTableSuffix;
+
+ protected String valueTableSuffix;
+
+ protected String refTableSuffix;
+
protected final String dialect;
+ protected final String workspaceName;
+
protected final boolean multiDb;
- protected final String workspaceName;
-
protected final List<String> cleaningScripts = new ArrayList<String>();
protected final List<String> committingScripts = new ArrayList<String>();
protected final List<String> rollbackingScripts = new
ArrayList<String>();
+ protected final WorkspaceEntry wsEntry;
+
/**
* DBCleaningScripts constructor.
*
@@ -61,15 +70,27 @@
*/
DBCleaningScripts(String dialect, RepositoryEntry rEntry) throws DBCleanException
{
- if (getMultiDbParameter(rEntry.getWorkspaceEntries().get(0)))
+ for (WorkspaceEntry wsEntry : rEntry.getWorkspaceEntries())
{
- throw new DBCleanException("Not supported operation.");
+ try
+ {
+ if (JDBCWorkspaceDataContainer.getDatabaseType(wsEntry).isMultiDatabase())
+ {
+ throw new DBCleanException("Not supported operation.");
+ }
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ throw new DBCleanException(e);
+ }
}
this.multiDb = false;
- this.tablePrefix = "S";
this.workspaceName = null;
this.dialect = dialect;
+ this.wsEntry = rEntry.getWorkspaceEntries().get(0);
+
+ initTableNames(wsEntry);
}
/**
@@ -79,10 +100,20 @@
*/
DBCleaningScripts(String dialect, WorkspaceEntry wsEntry) throws DBCleanException
{
- this.multiDb = getMultiDbParameter(wsEntry);
- this.tablePrefix = multiDb ? "M" : "S";
+ try
+ {
+ this.multiDb =
JDBCWorkspaceDataContainer.getDatabaseType(wsEntry).isMultiDatabase();
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ throw new DBCleanException(e);
+ }
+
this.workspaceName = wsEntry.getName();
this.dialect = dialect;
+ this.wsEntry = wsEntry;
+
+ initTableNames(wsEntry);
}
/**
@@ -217,8 +248,8 @@
{
List<String> scripts = new ArrayList<String>();
- String constraintName = "JCR_FK_" + tablePrefix +
"ITEM_PARENT";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM " +
constraintDroppingSyntax() + " " + constraintName);
+ String constraintName = "JCR_FK_" + itemTableSuffix +
"_PARENT";
+ scripts.add("ALTER TABLE " + itemTableName + " " +
constraintDroppingSyntax() + " " + constraintName);
return scripts;
}
@@ -231,8 +262,8 @@
List<String> scripts = new ArrayList<String>();
String constraintName =
- "JCR_FK_" + tablePrefix + "ITEM_PARENT FOREIGN KEY(PARENT_ID)
REFERENCES JCR_" + tablePrefix + "ITEM(ID)";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM ADD CONSTRAINT
" + constraintName);
+ "JCR_FK_" + itemTableSuffix + "_PARENT FOREIGN KEY(PARENT_ID)
REFERENCES " + itemTableName + "(ID)";
+ scripts.add("ALTER TABLE " + itemTableName + " ADD CONSTRAINT "
+ constraintName);
return scripts;
}
@@ -244,9 +275,9 @@
{
List<String> scripts = new ArrayList<String>();
- scripts.add("DROP TABLE JCR_" + tablePrefix + "VALUE_OLD");
- scripts.add("DROP TABLE JCR_" + tablePrefix + "ITEM_OLD");
- scripts.add("DROP TABLE JCR_" + tablePrefix + "REF_OLD");
+ scripts.add("DROP TABLE " + valueTableName + "_OLD");
+ scripts.add("DROP TABLE " + refTableName + "_OLD");
+ scripts.add("DROP TABLE " + itemTableName + "_OLD");
return scripts;
}
@@ -258,9 +289,9 @@
{
List<String> scripts = new ArrayList<String>();
- scripts.add("DROP TABLE JCR_" + tablePrefix + "VALUE");
- scripts.add("DROP TABLE JCR_" + tablePrefix + "ITEM");
- scripts.add("DROP TABLE JCR_" + tablePrefix + "REF");
+ scripts.add("DROP TABLE " + valueTableName);
+ scripts.add("DROP TABLE " + refTableName);
+ scripts.add("DROP TABLE " + itemTableName);
return scripts;
}
@@ -288,33 +319,27 @@
*/
protected Collection<String> getDBInitializationScripts() throws
DBCleanException
{
- String scriptPath = DBInitializerHelper.scriptPath(dialect, multiDb);
-
- String script;
+ String dbScripts;
try
{
- script =
IOUtil.getStreamContentAsString(PrivilegedFileHelper.getResourceAsStream(scriptPath));
+ dbScripts = DBInitializerHelper.prepareScripts(wsEntry, dialect);
}
- catch (FileNotFoundException e)
+ catch (IOException e)
{
throw new DBCleanException(e);
}
- catch (IllegalArgumentException e)
+ catch (RepositoryConfigurationException e)
{
throw new DBCleanException(e);
}
- catch (IOException e)
- {
- throw new DBCleanException(e);
- }
List<String> scripts = new ArrayList<String>();
- for (String query : JDBCUtils.splitWithSQLDelimiter(script))
+ for (String query : JDBCUtils.splitWithSQLDelimiter(dbScripts))
{
scripts.add(JDBCUtils.cleanWhitespaces(query));
}
- scripts.add(DBInitializerHelper.getRootNodeInitializeScript(multiDb));
+ scripts.add(DBInitializerHelper.getRootNodeInitializeScript(itemTableName,
multiDb));
return scripts;
}
@@ -327,14 +352,17 @@
return "DROP CONSTRAINT";
}
- /**
- * Return {@link JDBCWorkspaceDataContainer#MULTIDB} parameter from workspace
configuration.
- */
- private boolean getMultiDbParameter(WorkspaceEntry wsEntry) throws DBCleanException
+ private void initTableNames(WorkspaceEntry wsConfig) throws DBCleanException
{
try
{
- return
Boolean.parseBoolean(wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.MULTIDB));
+ itemTableName = DBInitializerHelper.getItemTableName(wsConfig);
+ refTableName = DBInitializerHelper.getRefTableName(wsConfig);
+ valueTableName = DBInitializerHelper.getValueTableName(wsConfig);
+
+ itemTableSuffix = DBInitializerHelper.getItemTableSuffix(wsConfig);
+ valueTableSuffix = DBInitializerHelper.getValueTableSuffix(wsConfig);
+ refTableSuffix = DBInitializerHelper.getRefTableSuffix(wsConfig);
}
catch (RepositoryConfigurationException e)
{
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScriptsFactory.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScriptsFactory.java 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScriptsFactory.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -22,6 +22,7 @@
import org.exoplatform.services.jcr.config.RepositoryEntry;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.impl.clean.rdbms.DBCleanException;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
/**
* @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
@@ -31,6 +32,13 @@
{
/**
* Prepare SQL scripts for cleaning workspace data from database.
+ *
+ * @param wsEntry
+ * workspace configuration
+ * @param dialect
+ * database dialect which is used, since {@link
JDBCWorkspaceDataContainer#DB_DIALECT} parameter
+ * can contain {@link DialectConstants#DB_DIALECT_AUTO} value it is necessary
to resolve dialect
+ * before based on database connection.
*/
public static DBCleaningScripts prepareScripts(String dialect, WorkspaceEntry wsEntry)
throws DBCleanException
{
@@ -75,6 +83,13 @@
/**
* Prepare SQL scripts for cleaning repository data from database.
+ *
+ * @param rEntry
+ * repository configuration
+ * @param dialect
+ * database dialect which is used, since {@link
JDBCWorkspaceDataContainer#DB_DIALECT} parameter
+ * can contain {@link DialectConstants#DB_DIALECT_AUTO} value it is necessary
to resolve dialect
+ * before based on database connection.
*/
public static DBCleaningScripts prepareScripts(String dialect, RepositoryEntry rEntry)
throws DBCleanException
{
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/HSQLDBCleaningScipts.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/HSQLDBCleaningScipts.java 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/HSQLDBCleaningScipts.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -66,29 +66,28 @@
Collection<String> scripts = new ArrayList<String>();
// renaming tables
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE RENAME TO
JCR_" + tablePrefix + "VALUE_OLD");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM RENAME TO
JCR_" + tablePrefix + "ITEM_OLD");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF RENAME TO
JCR_" + tablePrefix + "REF_OLD");
+ scripts.add("ALTER TABLE " + valueTableName + " RENAME TO " +
valueTableName + "_OLD");
+ scripts.add("ALTER TABLE " + itemTableName + " RENAME TO " +
itemTableName + "_OLD");
+ scripts.add("ALTER TABLE " + refTableName + " RENAME TO " +
refTableName + "_OLD");
// droping constraints
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE_OLD DROP
CONSTRAINT JCR_FK_" + tablePrefix
- + "VALUE_PROPERTY");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM_OLD DROP
CONSTRAINT JCR_FK_" + tablePrefix + "ITEM_PARENT");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM_OLD DROP
CONSTRAINT JCR_PK_" + tablePrefix + "ITEM");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE_OLD DROP
CONSTRAINT JCR_PK_" + tablePrefix + "VALUE");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF_OLD DROP
CONSTRAINT JCR_PK_" + tablePrefix + "REF");
+ scripts.add("ALTER TABLE " + valueTableName + "_OLD DROP CONSTRAINT
JCR_FK_" + valueTableSuffix + "_PROPERTY");
+ scripts.add("ALTER TABLE " + itemTableName + "_OLD DROP CONSTRAINT
JCR_FK_" + itemTableSuffix + "_PARENT");
+ scripts.add("ALTER TABLE " + itemTableName + "_OLD DROP CONSTRAINT
JCR_PK_" + itemTableSuffix);
+ scripts.add("ALTER TABLE " + valueTableName + "_OLD DROP CONSTRAINT
JCR_PK_" + valueTableSuffix);
+ scripts.add("ALTER TABLE " + refTableName + "_OLD DROP CONSTRAINT
JCR_PK_" + refTableSuffix);
// renaming indexes
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT
RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT_ID
RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT_ID_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix +
"ITEM_N_ORDER_NUM RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_N_ORDER_NUM_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "VALUE_PROPERTY
RENAME TO JCR_IDX_" + tablePrefix
- + "VALUE_PROPERTY_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "REF_PROPERTY
RENAME TO JCR_IDX_" + tablePrefix
- + "REF_PROPERTY_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_PARENT
RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_PARENT_ID
RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT_ID_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix +
"_N_ORDER_NUM RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_N_ORDER_NUM_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + valueTableSuffix + "_PROPERTY
RENAME TO JCR_IDX_" + valueTableSuffix
+ + "_PROPERTY_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + refTableSuffix + "_PROPERTY
RENAME TO JCR_IDX_" + refTableSuffix
+ + "_PROPERTY_OLD");
return scripts;
}
@@ -101,33 +100,31 @@
Collection<String> scripts = new ArrayList<String>();
// renaming tables
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE_OLD RENAME TO
JCR_" + tablePrefix + "VALUE");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM_OLD RENAME TO
JCR_" + tablePrefix + "ITEM");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF_OLD RENAME TO
JCR_" + tablePrefix + "REF");
+ scripts.add("ALTER TABLE " + valueTableName + "_OLD RENAME TO "
+ valueTableName);
+ scripts.add("ALTER TABLE " + itemTableName + "_OLD RENAME TO "
+ itemTableName);
+ scripts.add("ALTER TABLE " + refTableName + "_OLD RENAME TO " +
refTableName);
// creating constraints
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM ADD CONSTRAINT
JCR_PK_" + tablePrefix
- + "ITEM PRIMARY KEY(ID)");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE ADD
CONSTRAINT JCR_FK_" + tablePrefix
- + "VALUE_PROPERTY FOREIGN KEY(PROPERTY_ID) REFERENCES JCR_" +
tablePrefix + "ITEM(ID)");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM ADD CONSTRAINT
JCR_FK_" + tablePrefix
- + "ITEM_PARENT FOREIGN KEY(PARENT_ID) REFERENCES JCR_" + tablePrefix +
"ITEM(ID)");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE ADD
CONSTRAINT JCR_PK_" + tablePrefix
- + "VALUE PRIMARY KEY(ID)");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF ADD CONSTRAINT
JCR_PK_" + tablePrefix
- + "REF PRIMARY KEY(NODE_ID, PROPERTY_ID, ORDER_NUM)");
+ scripts.add("ALTER TABLE " + itemTableName + " ADD CONSTRAINT
JCR_PK_" + itemTableSuffix + " PRIMARY KEY(ID)");
+ scripts.add("ALTER TABLE " + valueTableName + " ADD CONSTRAINT
JCR_FK_" + valueTableSuffix
+ + "_PROPERTY FOREIGN KEY(PROPERTY_ID) REFERENCES " + itemTableName +
"(ID)");
+ scripts.add("ALTER TABLE " + itemTableName + " ADD CONSTRAINT
JCR_FK_" + itemTableSuffix
+ + "_PARENT FOREIGN KEY(PARENT_ID) REFERENCES " + itemTableName +
"(ID)");
+ scripts.add("ALTER TABLE " + valueTableName + " ADD CONSTRAINT
JCR_PK_" + valueTableSuffix + " PRIMARY KEY(ID)");
+ scripts.add("ALTER TABLE " + refTableName + " ADD CONSTRAINT
JCR_PK_" + refTableSuffix
+ + " PRIMARY KEY(NODE_ID, PROPERTY_ID, ORDER_NUM)");
// renaming indexes
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT_OLD
RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix +
"ITEM_PARENT_ID_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT_ID");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix +
"ITEM_N_ORDER_NUM_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_N_ORDER_NUM");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix +
"VALUE_PROPERTY_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "VALUE_PROPERTY");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix +
"REF_PROPERTY_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "REF_PROPERTY");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_PARENT_OLD
RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix +
"_PARENT_ID_OLD RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT_ID");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix +
"_N_ORDER_NUM_OLD RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_N_ORDER_NUM");
+ scripts.add("ALTER INDEX JCR_IDX_" + valueTableSuffix +
"_PROPERTY_OLD RENAME TO JCR_IDX_" + valueTableSuffix
+ + "_PROPERTY");
+ scripts.add("ALTER INDEX JCR_IDX_" + refTableSuffix +
"_PROPERTY_OLD RENAME TO JCR_IDX_" + refTableSuffix
+ + "_PROPERTY");
return scripts;
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/MySQLCleaningScipts.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/MySQLCleaningScipts.java 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/MySQLCleaningScipts.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -74,8 +74,8 @@
cleaningScripts.addAll(getIndexesDroppingScripts());
String constraintName =
- "JCR_FK_" + tablePrefix + "VALUE_PROPERTY FOREIGN
KEY(PROPERTY_ID) REFERENCES JCR_" + tablePrefix + "ITEM(ID)";
- committingScripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE ADD
CONSTRAINT " + constraintName);
+ "JCR_FK_" + valueTableSuffix + "_PROPERTY FOREIGN
KEY(PROPERTY_ID) REFERENCES " + itemTableName + "(ID)";
+ committingScripts.add("ALTER TABLE " + valueTableName + " ADD
CONSTRAINT " + constraintName);
}
/**
@@ -103,15 +103,14 @@
*/
private Collection<String> filter(Collection<String> scripts)
{
- String JCR_ITEM_PRIMARY_KEY = "CONSTRAINT JCR_PK_" + tablePrefix +
"ITEM PRIMARY KEY(ID)";
+ String JCR_ITEM_PRIMARY_KEY = "CONSTRAINT JCR_PK_" + itemTableSuffix +
" PRIMARY KEY(ID)";
String JCR_ITEM_FOREIGN_KEY =
- "CONSTRAINT JCR_FK_" + tablePrefix + "ITEM_PARENT FOREIGN
KEY(PARENT_ID) REFERENCES JCR_" + tablePrefix
- + "ITEM(ID)";
+ "CONSTRAINT JCR_FK_" + itemTableSuffix + "_PARENT FOREIGN
KEY(PARENT_ID) REFERENCES " + itemTableName + "(ID)";
- String JCR_VALUE_PRIMARY_KEY = "CONSTRAINT JCR_PK_" + tablePrefix +
"VALUE PRIMARY KEY(ID)";
+ String JCR_VALUE_PRIMARY_KEY = "CONSTRAINT JCR_PK_" + valueTableSuffix +
" PRIMARY KEY(ID)";
String JCR_VALUE_FOREIGN_KEY =
- "CONSTRAINT JCR_FK_" + tablePrefix + "VALUE_PROPERTY FOREIGN
KEY(PROPERTY_ID) REFERENCES JCR_" + tablePrefix
- + "ITEM(ID)";
+ "CONSTRAINT JCR_FK_" + valueTableSuffix + "_PROPERTY FOREIGN
KEY(PROPERTY_ID) REFERENCES " + itemTableName
+ + "(ID)";
Collection<String> filteredScripts = new ArrayList<String>();
@@ -141,9 +140,9 @@
{
Collection<String> scripts = new ArrayList<String>();
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE RENAME TO
JCR_" + tablePrefix + "VALUE_OLD");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM RENAME TO
JCR_" + tablePrefix + "ITEM_OLD");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF RENAME TO
JCR_" + tablePrefix + "REF_OLD");
+ scripts.add("ALTER TABLE " + valueTableName + " RENAME TO " +
valueTableName + "_OLD");
+ scripts.add("ALTER TABLE " + itemTableName + " RENAME TO " +
itemTableName + "_OLD");
+ scripts.add("ALTER TABLE " + refTableName + " RENAME TO " +
refTableName + "_OLD");
return scripts;
}
@@ -155,9 +154,9 @@
{
Collection<String> scripts = new ArrayList<String>();
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM_OLD RENAME TO
JCR_" + tablePrefix + "ITEM");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE_OLD RENAME TO
JCR_" + tablePrefix + "VALUE");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF_OLD RENAME TO
JCR_" + tablePrefix + "REF");
+ scripts.add("ALTER TABLE " + itemTableName + "_OLD RENAME TO "
+ itemTableName);
+ scripts.add("ALTER TABLE " + valueTableName + "_OLD RENAME TO "
+ valueTableName);
+ scripts.add("ALTER TABLE " + refTableName + "_OLD RENAME TO " +
refTableName);
return scripts;
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/OracleCleaningScipts.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/OracleCleaningScipts.java 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/OracleCleaningScipts.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -24,6 +24,7 @@
import org.exoplatform.services.jcr.impl.clean.rdbms.DBCleanException;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@@ -61,7 +62,7 @@
prepareSimpleCleaningApproachScripts();
}
}
-
+
/**
* R{@inheritDoc}
*/
@@ -69,18 +70,18 @@
{
Collection<String> scripts = new ArrayList<String>();
- String constraintName = "JCR_PK_" + tablePrefix + "VALUE PRIMARY
KEY(ID)";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE ADD CONSTRAINT
" + constraintName);
+ String constraintName = "JCR_PK_" + valueTableSuffix + " PRIMARY
KEY(ID)";
+ scripts.add("ALTER TABLE " + valueTableName + " ADD CONSTRAINT
" + constraintName);
- constraintName = "JCR_PK_" + tablePrefix + "ITEM PRIMARY
KEY(ID)";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM ADD CONSTRAINT
" + constraintName);
+ constraintName = "JCR_PK_" + itemTableSuffix + " PRIMARY
KEY(ID)";
+ scripts.add("ALTER TABLE " + itemTableName + " ADD CONSTRAINT "
+ constraintName);
constraintName =
- "JCR_FK_" + tablePrefix + "VALUE_PROPERTY FOREIGN
KEY(PROPERTY_ID) REFERENCES JCR_" + tablePrefix + "ITEM(ID)";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE ADD CONSTRAINT
" + constraintName);
+ "JCR_FK_" + valueTableSuffix + "_PROPERTY FOREIGN
KEY(PROPERTY_ID) REFERENCES " + itemTableName + "(ID)";
+ scripts.add("ALTER TABLE " + valueTableName + " ADD CONSTRAINT
" + constraintName);
- constraintName = "JCR_PK_" + tablePrefix + "REF PRIMARY KEY(NODE_ID,
PROPERTY_ID, ORDER_NUM)";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF ADD CONSTRAINT
" + constraintName);
+ constraintName = "JCR_PK_" + refTableSuffix + " PRIMARY KEY(NODE_ID,
PROPERTY_ID, ORDER_NUM)";
+ scripts.add("ALTER TABLE " + refTableName + " ADD CONSTRAINT "
+ constraintName);
return scripts;
}
@@ -92,17 +93,17 @@
{
Collection<String> scripts = new ArrayList<String>();
- String constraintName = "JCR_PK_" + tablePrefix + "VALUE";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE DROP
CONSTRAINT " + constraintName);
+ String constraintName = "JCR_PK_" + valueTableSuffix;
+ scripts.add("ALTER TABLE " + valueTableName + " DROP CONSTRAINT
" + constraintName);
- constraintName = "JCR_FK_" + tablePrefix + "VALUE_PROPERTY";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE DROP
CONSTRAINT " + constraintName);
+ constraintName = "JCR_FK_" + valueTableSuffix + "_PROPERTY";
+ scripts.add("ALTER TABLE " + valueTableName + " DROP CONSTRAINT
" + constraintName);
- constraintName = "JCR_PK_" + tablePrefix + "ITEM";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM DROP CONSTRAINT
" + constraintName);
+ constraintName = "JCR_PK_" + itemTableSuffix;
+ scripts.add("ALTER TABLE " + itemTableName + " DROP CONSTRAINT
" + constraintName);
- constraintName = "JCR_PK_" + tablePrefix + "REF";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF DROP CONSTRAINT
" + constraintName);
+ constraintName = "JCR_PK_" + refTableSuffix;
+ scripts.add("ALTER TABLE " + refTableName + " DROP CONSTRAINT "
+ constraintName);
return scripts;
}
@@ -114,12 +115,12 @@
{
Collection<String> scripts = new ArrayList<String>();
- scripts.add("DROP INDEX JCR_IDX_" + tablePrefix +
"ITEM_PARENT_FK");
- scripts.add("DROP INDEX JCR_IDX_" + tablePrefix +
"ITEM_PARENT");
- scripts.add("DROP INDEX JCR_IDX_" + tablePrefix +
"ITEM_PARENT_ID");
- scripts.add("DROP INDEX JCR_IDX_" + tablePrefix +
"ITEM_N_ORDER_NUM");
- scripts.add("DROP INDEX JCR_IDX_" + tablePrefix +
"VALUE_PROPERTY");
- scripts.add("DROP INDEX JCR_IDX_" + tablePrefix +
"REF_PROPERTY");
+ scripts.add("DROP INDEX JCR_IDX_" + itemTableSuffix +
"_PARENT_FK");
+ scripts.add("DROP INDEX JCR_IDX_" + itemTableSuffix +
"_PARENT");
+ scripts.add("DROP INDEX JCR_IDX_" + itemTableSuffix +
"_PARENT_ID");
+ scripts.add("DROP INDEX JCR_IDX_" + itemTableSuffix +
"_N_ORDER_NUM");
+ scripts.add("DROP INDEX JCR_IDX_" + valueTableSuffix +
"_PROPERTY");
+ scripts.add("DROP INDEX JCR_IDX_" + refTableSuffix +
"_PROPERTY");
return scripts;
}
@@ -133,23 +134,27 @@
try
{
- scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" +
tablePrefix + "ITEM_PARENT_FK ON JCR_"
- + tablePrefix + "ITEM", multiDb, dialect));
- scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" +
tablePrefix + "ITEM_PARENT ON JCR_" + tablePrefix
- + "ITEM", multiDb, dialect));
- scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" +
tablePrefix + "ITEM_PARENT_ID ON JCR_"
- + tablePrefix + "ITEM", multiDb, dialect));
- scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" +
tablePrefix + "ITEM_N_ORDER_NUM ON JCR_"
- + tablePrefix + "ITEM", multiDb, dialect));
- scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" +
tablePrefix + "VALUE_PROPERTY ON JCR_"
- + tablePrefix + "VALUE", multiDb, dialect));
- scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" +
tablePrefix + "REF_PROPERTY ON JCR_"
- + tablePrefix + "REF", multiDb, dialect));
+ scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" +
itemTableSuffix + "_PARENT_FK ON "
+ + itemTableName, multiDb, dialect, wsEntry));
+ scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" +
itemTableSuffix + "_PARENT ON " + itemTableName,
+ multiDb, dialect, wsEntry));
+ scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" +
itemTableSuffix + "_PARENT_ID ON "
+ + itemTableName, multiDb, dialect, wsEntry));
+ scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" +
itemTableSuffix + "_N_ORDER_NUM ON "
+ + itemTableName, multiDb, dialect, wsEntry));
+ scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" +
valueTableSuffix + "_PROPERTY ON "
+ + valueTableName, multiDb, dialect, wsEntry));
+ scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" +
refTableSuffix + "_PROPERTY ON " + refTableName,
+ multiDb, dialect, wsEntry));
}
catch (RepositoryConfigurationException e)
{
throw new DBCleanException(e);
}
+ catch (IOException e)
+ {
+ throw new DBCleanException(e);
+ }
return scripts;
}
@@ -161,8 +166,8 @@
{
Collection<String> scripts = new ArrayList<String>();
- scripts.add("DROP TRIGGER BI_JCR_" + tablePrefix + "VALUE");
- scripts.add("DROP SEQUENCE JCR_" + tablePrefix + "VALUE_SEQ");
+ scripts.add("DROP TRIGGER BI_" + valueTableName + "");
+ scripts.add("DROP SEQUENCE " + valueTableName + "_SEQ");
scripts.addAll(super.getTablesDroppingScripts());
@@ -176,8 +181,8 @@
{
Collection<String> scripts = new ArrayList<String>();
- scripts.add("DROP TRIGGER BI_JCR_" + tablePrefix +
"VALUE_OLD");
- scripts.add("DROP SEQUENCE JCR_" + tablePrefix +
"VALUE_SEQ_OLD");
+ scripts.add("DROP TRIGGER BI_" + valueTableName + "_OLD");
+ scripts.add("DROP SEQUENCE " + valueTableName + "_SEQ_OLD");
scripts.addAll(super.getOldTablesDroppingScripts());
@@ -192,45 +197,45 @@
Collection<String> scripts = new ArrayList<String>();
// JCR_VALUE
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE RENAME TO
JCR_" + tablePrefix + "VALUE_OLD");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE_OLD" +
" RENAME CONSTRAINT JCR_PK_" + tablePrefix
- + "VALUE TO JCR_PK_" + tablePrefix + "VALUE_OLD");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE_OLD" +
" RENAME CONSTRAINT JCR_FK_" + tablePrefix
- + "VALUE_PROPERTY TO JCR_FK_" + tablePrefix +
"VALUE_PROPERTY_OLD");
+ scripts.add("ALTER TABLE " + valueTableName + " RENAME TO " +
valueTableName + "_OLD");
+ scripts.add("ALTER TABLE " + valueTableName + "_OLD" + "
RENAME CONSTRAINT JCR_PK_" + valueTableSuffix
+ + " TO JCR_PK_" + valueTableSuffix + "_OLD");
+ scripts.add("ALTER TABLE " + valueTableName + "_OLD" + "
RENAME CONSTRAINT JCR_FK_" + valueTableSuffix
+ + "_PROPERTY TO JCR_FK_" + valueTableSuffix +
"_PROPERTY_OLD");
- scripts.add("ALTER INDEX JCR_PK_" + tablePrefix + "VALUE RENAME TO
JCR_PK_" + tablePrefix + "VALUE_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "VALUE_PROPERTY
RENAME TO JCR_IDX_" + tablePrefix
- + "VALUE_PROPERTY_OLD");
+ scripts.add("ALTER INDEX JCR_PK_" + valueTableSuffix + " RENAME TO
JCR_PK_" + valueTableSuffix + "_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + valueTableSuffix + "_PROPERTY
RENAME TO JCR_IDX_" + valueTableSuffix
+ + "_PROPERTY_OLD");
// TRIGGER and SEQ
- scripts.add("RENAME JCR_" + tablePrefix + "VALUE_SEQ TO JCR_" +
tablePrefix + "VALUE_SEQ_OLD");
- scripts.add("ALTER TRIGGER BI_JCR_" + tablePrefix + "VALUE RENAME TO
BI_JCR_" + tablePrefix + "VALUE_OLD");
+ scripts.add("RENAME " + valueTableName + "_SEQ TO " +
valueTableName + "_SEQ_OLD");
+ scripts.add("ALTER TRIGGER BI_" + valueTableName + " RENAME TO
BI_" + valueTableName + "_OLD");
// JCR_ITEM
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM RENAME TO
JCR_" + tablePrefix + "ITEM_OLD");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM_OLD RENAME
CONSTRAINT JCR_PK_" + tablePrefix
- + "ITEM TO JCR_PK_" + tablePrefix + "ITEM_OLD");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM_OLD RENAME
CONSTRAINT JCR_FK_" + tablePrefix
- + "ITEM_PARENT TO JCR_FK_" + tablePrefix +
"ITEM_PARENT_OLD");
+ scripts.add("ALTER TABLE " + itemTableName + " RENAME TO " +
itemTableName + "_OLD");
+ scripts.add("ALTER TABLE " + itemTableName + "_OLD RENAME CONSTRAINT
JCR_PK_" + itemTableSuffix + " TO JCR_PK_"
+ + itemTableSuffix + "_OLD");
+ scripts.add("ALTER TABLE " + itemTableName + "_OLD RENAME CONSTRAINT
JCR_FK_" + itemTableSuffix
+ + "_PARENT TO JCR_FK_" + itemTableSuffix + "_PARENT_OLD");
- scripts.add("ALTER INDEX JCR_PK_" + tablePrefix + "ITEM RENAME TO
JCR_PK_" + tablePrefix + "ITEM_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT_FK
RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT_FK_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT
RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT_ID
RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT_ID_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_N_ORDER_NUM
RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_N_ORDER_NUM_OLD");
+ scripts.add("ALTER INDEX JCR_PK_" + itemTableSuffix + " RENAME TO
JCR_PK_" + itemTableSuffix + "_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_PARENT_FK
RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT_FK_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_PARENT
RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_PARENT_ID
RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT_ID_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_N_ORDER_NUM
RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_N_ORDER_NUM_OLD");
// JCR_REF
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF RENAME TO
JCR_" + tablePrefix + "REF_OLD");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF_OLD RENAME
CONSTRAINT JCR_PK_" + tablePrefix
- + "REF TO JCR_PK_" + tablePrefix + "REF_OLD");
+ scripts.add("ALTER TABLE " + refTableName + " RENAME TO " +
refTableName + "_OLD");
+ scripts.add("ALTER TABLE " + refTableName + "_OLD RENAME CONSTRAINT
JCR_PK_" + refTableSuffix + " TO JCR_PK_"
+ + refTableSuffix + "_OLD");
- scripts.add("ALTER INDEX JCR_PK_" + tablePrefix + "REF RENAME TO
JCR_PK_" + tablePrefix + "REF_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "REF_PROPERTY
RENAME TO JCR_IDX_" + tablePrefix
- + "REF_PROPERTY_OLD");
+ scripts.add("ALTER INDEX JCR_PK_" + refTableSuffix + " RENAME TO
JCR_PK_" + refTableSuffix + "_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + refTableSuffix + "_PROPERTY
RENAME TO JCR_IDX_" + refTableSuffix
+ + "_PROPERTY_OLD");
return scripts;
}
@@ -243,42 +248,42 @@
Collection<String> scripts = new ArrayList<String>();
// VALUE
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE_OLD RENAME TO
JCR_" + tablePrefix + "VALUE");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE RENAME
CONSTRAINT JCR_PK_" + tablePrefix
- + "VALUE_OLD TO JCR_PK_" + tablePrefix + "VALUE");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE RENAME
CONSTRAINT JCR_FK_" + tablePrefix
- + "VALUE_PROPERTY_OLD TO JCR_FK_" + tablePrefix +
"VALUE_PROPERTY");
- scripts.add("ALTER INDEX JCR_PK_" + tablePrefix + "VALUE_OLD RENAME
TO JCR_PK_" + tablePrefix + "VALUE");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix +
"VALUE_PROPERTY_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "VALUE_PROPERTY");
+ scripts.add("ALTER TABLE " + valueTableName + "_OLD RENAME TO "
+ valueTableName + "");
+ scripts.add("ALTER TABLE " + valueTableName + " RENAME CONSTRAINT
JCR_PK_" + valueTableSuffix + "_OLD TO JCR_PK_"
+ + valueTableSuffix);
+ scripts.add("ALTER TABLE " + valueTableName + " RENAME CONSTRAINT
JCR_FK_" + valueTableSuffix
+ + "_PROPERTY_OLD TO JCR_FK_" + valueTableSuffix +
"_PROPERTY");
+ scripts.add("ALTER INDEX JCR_PK_" + valueTableSuffix + "_OLD RENAME
TO JCR_PK_" + valueTableSuffix);
+ scripts.add("ALTER INDEX JCR_IDX_" + valueTableSuffix +
"_PROPERTY_OLD RENAME TO JCR_IDX_" + valueTableSuffix
+ + "_PROPERTY");
// TRIGGER and SEQ
- scripts.add("RENAME JCR_" + tablePrefix + "VALUE_SEQ_OLD TO
JCR_" + tablePrefix + "VALUE_SEQ");
- scripts.add("ALTER TRIGGER BI_JCR_" + tablePrefix + "VALUE_OLD
RENAME TO BI_JCR_" + tablePrefix + "VALUE");
+ scripts.add("RENAME " + valueTableName + "_SEQ_OLD TO " +
valueTableName + "_SEQ");
+ scripts.add("ALTER TRIGGER BI_" + valueTableName + "_OLD RENAME TO
BI_" + valueTableName + "");
// ITEM
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM_OLD RENAME TO
JCR_" + tablePrefix + "ITEM");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM RENAME
CONSTRAINT JCR_PK_" + tablePrefix
- + "ITEM_OLD TO JCR_PK_" + tablePrefix + "ITEM");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM RENAME
CONSTRAINT JCR_FK_" + tablePrefix
- + "ITEM_PARENT_OLD TO JCR_FK_" + tablePrefix +
"ITEM_PARENT");
- scripts.add("ALTER INDEX JCR_PK_" + tablePrefix + "ITEM_OLD RENAME
TO JCR_PK_" + tablePrefix + "ITEM");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix +
"ITEM_PARENT_FK_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT_FK");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT_OLD
RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix +
"ITEM_PARENT_ID_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT_ID");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix +
"ITEM_N_ORDER_NUM_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_N_ORDER_NUM");
+ scripts.add("ALTER TABLE " + itemTableName + "_OLD RENAME TO "
+ itemTableName + "");
+ scripts.add("ALTER TABLE " + itemTableName + " RENAME CONSTRAINT
JCR_PK_" + itemTableSuffix + "_OLD TO JCR_PK_"
+ + itemTableSuffix);
+ scripts.add("ALTER TABLE " + itemTableName + " RENAME CONSTRAINT
JCR_FK_" + itemTableSuffix
+ + "_PARENT_OLD TO JCR_FK_" + itemTableSuffix + "_PARENT");
+ scripts.add("ALTER INDEX JCR_PK_" + itemTableSuffix + "_OLD RENAME
TO JCR_PK_" + itemTableSuffix);
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix +
"_PARENT_FK_OLD RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT_FK");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_PARENT_OLD
RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix +
"_PARENT_ID_OLD RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT_ID");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix +
"_N_ORDER_NUM_OLD RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_N_ORDER_NUM");
// REF
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF_OLD RENAME TO
JCR_" + tablePrefix + "REF");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF RENAME
CONSTRAINT JCR_PK_" + tablePrefix
- + "REF_OLD TO JCR_PK_" + tablePrefix + "REF");
- scripts.add("ALTER INDEX JCR_PK_" + tablePrefix + "REF_OLD RENAME TO
JCR_PK_" + tablePrefix + "REF");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "REF_PROPERTY_OLD
RENAME TO JCR_IDX_" + tablePrefix
- + "REF_PROPERTY");
+ scripts.add("ALTER TABLE " + refTableName + "_OLD RENAME TO " +
refTableName + "");
+ scripts.add("ALTER TABLE " + refTableName + " RENAME CONSTRAINT
JCR_PK_" + refTableSuffix + "_OLD TO JCR_PK_"
+ + refTableSuffix);
+ scripts.add("ALTER INDEX JCR_PK_" + refTableSuffix + "_OLD RENAME TO
JCR_PK_" + refTableSuffix);
+ scripts.add("ALTER INDEX JCR_IDX_" + refTableSuffix + "_PROPERTY_OLD
RENAME TO JCR_IDX_" + refTableSuffix
+ + "_PROPERTY");
return scripts;
}
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/SybaseCleaningScipts.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/SybaseCleaningScipts.java 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/SybaseCleaningScipts.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -24,6 +24,7 @@
import org.exoplatform.services.jcr.impl.clean.rdbms.DBCleanException;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@@ -69,15 +70,15 @@
{
Collection<String> scripts = new ArrayList<String>();
- String constraintName = "JCR_PK_" + tablePrefix + "ITEM PRIMARY
KEY(ID)";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM ADD CONSTRAINT
" + constraintName);
+ String constraintName = "JCR_PK_" + itemTableSuffix + " PRIMARY
KEY(ID)";
+ scripts.add("ALTER TABLE " + itemTableName + " ADD CONSTRAINT "
+ constraintName);
- constraintName = "JCR_PK_" + tablePrefix + "VALUE PRIMARY
KEY(ID)";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE ADD CONSTRAINT
" + constraintName);
+ constraintName = "JCR_PK_" + valueTableSuffix + " PRIMARY
KEY(ID)";
+ scripts.add("ALTER TABLE " + valueTableName + " ADD CONSTRAINT
" + constraintName);
constraintName =
- "JCR_FK_" + tablePrefix + "VALUE_PROPERTY FOREIGN
KEY(PROPERTY_ID) REFERENCES JCR_" + tablePrefix + "ITEM(ID)";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE ADD CONSTRAINT
" + constraintName);
+ "JCR_FK_" + valueTableSuffix + "_PROPERTY FOREIGN
KEY(PROPERTY_ID) REFERENCES " + itemTableName + "(ID)";
+ scripts.add("ALTER TABLE " + valueTableName + " ADD CONSTRAINT
" + constraintName);
return scripts;
}
@@ -89,14 +90,14 @@
{
Collection<String> scripts = new ArrayList<String>();
- String constraintName = "JCR_FK_" + tablePrefix +
"VALUE_PROPERTY";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE DROP
CONSTRAINT " + constraintName);
+ String constraintName = "JCR_FK_" + valueTableSuffix +
"_PROPERTY";
+ scripts.add("ALTER TABLE " + valueTableName + " DROP CONSTRAINT
" + constraintName);
- constraintName = "JCR_PK_" + tablePrefix + "ITEM";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM DROP
CONSTRAINT " + constraintName);
+ constraintName = "JCR_PK_" + itemTableSuffix;
+ scripts.add("ALTER TABLE " + itemTableName + " DROP CONSTRAINT
" + constraintName);
- constraintName = "JCR_PK_" + tablePrefix + "VALUE";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE DROP
CONSTRAINT " + constraintName);
+ constraintName = "JCR_PK_" + valueTableSuffix;
+ scripts.add("ALTER TABLE " + valueTableName + " DROP CONSTRAINT
" + constraintName);
return scripts;
}
@@ -108,11 +109,11 @@
{
Collection<String> scripts = new ArrayList<String>();
- scripts.add("DROP INDEX JCR_" + tablePrefix + "ITEM.JCR_IDX_" +
tablePrefix + "ITEM_PARENT");
- scripts.add("DROP INDEX JCR_" + tablePrefix + "ITEM.JCR_IDX_" +
tablePrefix + "ITEM_PARENT_ID");
- scripts.add("DROP INDEX JCR_" + tablePrefix + "ITEM.JCR_IDX_" +
tablePrefix + "ITEM_N_ORDER_NUM");
- scripts.add("DROP INDEX JCR_" + tablePrefix + "VALUE.JCR_IDX_"
+ tablePrefix + "VALUE_PROPERTY");
- scripts.add("DROP INDEX JCR_" + tablePrefix + "REF.JCR_IDX_" +
tablePrefix + "REF_PROPERTY");
+ scripts.add("DROP INDEX " + itemTableName + ".JCR_IDX_" +
itemTableSuffix + "_PARENT");
+ scripts.add("DROP INDEX " + itemTableName + ".JCR_IDX_" +
itemTableSuffix + "_PARENT_ID");
+ scripts.add("DROP INDEX " + itemTableName + ".JCR_IDX_" +
itemTableSuffix + "_N_ORDER_NUM");
+ scripts.add("DROP INDEX " + valueTableName + ".JCR_IDX_" +
valueTableSuffix + "_PROPERTY");
+ scripts.add("DROP INDEX " + refTableName + ".JCR_IDX_" +
refTableSuffix + "_PROPERTY");
return scripts;
}
@@ -126,21 +127,25 @@
try
{
- scripts.add(DBInitializerHelper.getObjectScript("INDEX JCR_IDX_" +
tablePrefix + "ITEM_PARENT ON JCR_"
- + tablePrefix + "ITEM", multiDb, dialect));
- scripts.add(DBInitializerHelper.getObjectScript("INDEX JCR_IDX_" +
tablePrefix + "ITEM_PARENT_ID ON JCR_"
- + tablePrefix + "ITEM", multiDb, dialect));
- scripts.add(DBInitializerHelper.getObjectScript("INDEX JCR_IDX_" +
tablePrefix + "ITEM_N_ORDER_NUM ON JCR_"
- + tablePrefix + "ITEM", multiDb, dialect));
- scripts.add(DBInitializerHelper.getObjectScript("INDEX JCR_IDX_" +
tablePrefix + "VALUE_PROPERTY ON JCR_"
- + tablePrefix + "VALUE", multiDb, dialect));
- scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" +
tablePrefix + "REF_PROPERTY ON JCR_"
- + tablePrefix + "REF", multiDb, dialect));
+ scripts.add(DBInitializerHelper.getObjectScript("INDEX JCR_IDX_" +
itemTableSuffix + "_PARENT ON "
+ + itemTableName, multiDb, dialect, wsEntry));
+ scripts.add(DBInitializerHelper.getObjectScript("INDEX JCR_IDX_" +
itemTableSuffix + "_PARENT_ID ON "
+ + itemTableName, multiDb, dialect, wsEntry));
+ scripts.add(DBInitializerHelper.getObjectScript("INDEX JCR_IDX_" +
itemTableSuffix + "_N_ORDER_NUM ON "
+ + itemTableName, multiDb, dialect, wsEntry));
+ scripts.add(DBInitializerHelper.getObjectScript("INDEX JCR_IDX_" +
valueTableSuffix + "_PROPERTY ON "
+ + valueTableName, multiDb, dialect, wsEntry));
+ scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" +
refTableSuffix + "_PROPERTY ON " + refTableName,
+ multiDb, dialect, wsEntry));
}
catch (RepositoryConfigurationException e)
{
throw new DBCleanException(e);
}
+ catch (IOException e)
+ {
+ throw new DBCleanException(e);
+ }
return scripts;
}
@@ -152,12 +157,12 @@
{
Collection<String> scripts = new ArrayList<String>();
- scripts.add("sp_rename JCR_" + tablePrefix + "VALUE, JCR_" +
tablePrefix + "VALUE_OLD");
- scripts.add("sp_rename JCR_" + tablePrefix + "ITEM, JCR_" +
tablePrefix + "ITEM_OLD");
- scripts.add("sp_rename JCR_" + tablePrefix + "REF, JCR_" +
tablePrefix + "REF_OLD");
+ scripts.add("sp_rename " + valueTableName + ", " +
valueTableName + "_OLD");
+ scripts.add("sp_rename " + itemTableName + ", " + itemTableName
+ "_OLD");
+ scripts.add("sp_rename " + refTableName + ", " + refTableName +
"_OLD");
- scripts.add("sp_rename JCR_FK_" + tablePrefix + "VALUE_PROPERTY,
JCR_FK_" + tablePrefix + "VALUE_PROPERTY_OLD");
- scripts.add("sp_rename JCR_FK_" + tablePrefix + "ITEM_PARENT,
JCR_FK_" + tablePrefix + "ITEM_PARENT_OLD");
+ scripts.add("sp_rename JCR_FK_" + valueTableSuffix + "_PROPERTY,
JCR_FK_" + valueTableSuffix + "_PROPERTY_OLD");
+ scripts.add("sp_rename JCR_FK_" + itemTableSuffix + "_PARENT,
JCR_FK_" + itemTableSuffix + "_PARENT_OLD");
return scripts;
}
@@ -169,12 +174,12 @@
{
Collection<String> scripts = new ArrayList<String>();
- scripts.add("sp_rename JCR_" + tablePrefix + "VALUE_OLD, JCR_"
+ tablePrefix + "VALUE");
- scripts.add("sp_rename JCR_" + tablePrefix + "ITEM_OLD, JCR_" +
tablePrefix + "ITEM");
- scripts.add("sp_rename JCR_" + tablePrefix + "REF_OLD, JCR_" +
tablePrefix + "REF");
+ scripts.add("sp_rename " + valueTableName + "_OLD, " +
valueTableName);
+ scripts.add("sp_rename " + itemTableName + "_OLD, " +
itemTableName);
+ scripts.add("sp_rename " + refTableName + "_OLD, " +
refTableName);
- scripts.add("sp_rename JCR_FK_" + tablePrefix + "VALUE_PROPERTY_OLD,
JCR_FK_" + tablePrefix + "VALUE_PROPERTY");
- scripts.add("sp_rename JCR_FK_" + tablePrefix + "ITEM_PARENT_OLD,
JCR_FK_" + tablePrefix + "ITEM_PARENT");
+ scripts.add("sp_rename JCR_FK_" + valueTableSuffix + "_PROPERTY_OLD,
JCR_FK_" + valueTableSuffix + "_PROPERTY");
+ scripts.add("sp_rename JCR_FK_" + itemTableSuffix + "_PARENT_OLD,
JCR_FK_" + itemTableSuffix + "_PARENT");
return scripts;
}
Deleted:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JBCShareableLockTableHandler.java.orig
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JBCShareableLockTableHandler.java.orig 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JBCShareableLockTableHandler.java.orig 2012-03-14
13:28:03 UTC (rev 5863)
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2003-2010 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not,
see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.jcr.impl.core.lock.jbosscache;
-
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.impl.checker.InspectionQuery;
-import org.exoplatform.services.jcr.impl.core.lock.LockTableHandler;
-
-import java.sql.SQLException;
-
-/**
- * Provides means for nodes' IDs extraction in case we use {@link
CacheableLockManagerImpl}
- * as {@link LockManager} based on shareable JBoss Cache instance.
- * Equally applicable for single and multi db configurations.
- *
- * @author <a href="mailto:dkuleshov@exoplatform.com">Dmitry
Kuleshov</a>
- * @version $Id: JBCShareableLockTableHandler.java 34360 2009-07-22 23:58:59Z dkuleshov
$
- *
- */
-public class JBCShareableLockTableHandler extends JBCLockTableHandler implements
LockTableHandler
-{
-
- /**
- * JBCShareableLockTableHandler constructor.
- */
- public JBCShareableLockTableHandler(WorkspaceEntry workspaceEntry)
- {
- super(workspaceEntry);
- }
-
- /**
- * {@inheritDoc}
- */
- protected InspectionQuery getSelectQuery() throws SQLException
- {
- return new InspectionQuery("SELECT * FROM " + getTableName() + "
WHERE " + getParentColumn() + "='/"
- + workspaceEntry.getUniqueName() + "/" +
CacheableLockManagerImpl.LOCKS + "'", new String[]{getIdColumn()},
- "Locks table match");
- }
-
- protected InspectionQuery getDeleteQuery(String nodeId) throws SQLException
- {
- return new InspectionQuery("DELETE FROM " + getTableName() + " WHERE
" + getIdColumn() + "='/"
- + workspaceEntry.getUniqueName() + "/" +
CacheableLockManagerImpl.LOCKS + "/" + nodeId + "'", new
String[]{},
- "");
- }
-
-}
\ 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/JDBCDataContainerConfig.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCDataContainerConfig.java 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCDataContainerConfig.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -38,14 +38,8 @@
*/
MULTI {
@Override
- public boolean isSingleDatabase()
+ public boolean isMultiDatabase()
{
- return false;
- }
-
- @Override
- public boolean isSimpleTable()
- {
return true;
}
},
@@ -55,14 +49,8 @@
*/
SINGLE {
@Override
- public boolean isSingleDatabase()
+ public boolean isMultiDatabase()
{
- return true;
- }
-
- @Override
- public boolean isSimpleTable()
- {
return false;
}
},
@@ -73,28 +61,16 @@
*/
ISOLATED {
@Override
- public boolean isSingleDatabase()
+ public boolean isMultiDatabase()
{
return true;
}
-
- @Override
- public boolean isSimpleTable()
- {
- return true;
- }
};
/**
- * @return true if database structure type requires same database for workspaces
within one repository
+ * @return true if every workspace stores data in separate table 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?
-
+ public abstract boolean isMultiDatabase();
}
/**
@@ -113,31 +89,11 @@
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;
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-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -48,20 +48,20 @@
import org.exoplatform.services.jcr.impl.dataflow.serialization.ObjectReaderImpl;
import org.exoplatform.services.jcr.impl.dataflow.serialization.ObjectWriterImpl;
import org.exoplatform.services.jcr.impl.storage.WorkspaceDataContainerBase;
+import
org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig.DatabaseStructureType;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.GenericConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.HSQLDBConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.MySQLConnectionFactory;
-import org.exoplatform.services.jcr.impl.storage.jdbc.db.OracleConnectionFactory;
import
org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
import
org.exoplatform.services.jcr.impl.storage.jdbc.indexing.JdbcNodeDataIndexingIterator;
import org.exoplatform.services.jcr.impl.storage.jdbc.init.IngresSQLDBInitializer;
import org.exoplatform.services.jcr.impl.storage.jdbc.init.OracleDBInitializer;
import org.exoplatform.services.jcr.impl.storage.jdbc.init.PgSQLDBInitializer;
-import org.exoplatform.services.jcr.impl.storage.jdbc.init.StorageDBInitializer;
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.FileCleanerHolder;
+import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerException;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
@@ -80,7 +80,6 @@
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.sql.Connection;
-import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
@@ -121,8 +120,6 @@
}
}
- //configuration params
-
public final static String SOURCE_NAME = "source-name";
@Deprecated
@@ -143,14 +140,6 @@
*/
public final static String DB_DIALECT = "dialect";
- public final static String DB_DRIVER = "driverClassName";
-
- public final static String DB_URL = "url";
-
- public final static String DB_USERNAME = "username";
-
- public final static String DB_PASSWORD = "password";
-
public final static String DB_FORCE_QUERY_HINTS = "force.query.hints";
protected JDBCDataContainerConfig containerConfig;
@@ -222,11 +211,9 @@
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.dbTableSuffix = getDBTableSuffix(wsConfig);
- this.containerConfig.multiDb =
!containerConfig.dbStructureType.isSingleDatabase();
+ this.containerConfig.multiDb = containerConfig.dbStructureType.isMultiDatabase();
this.containerConfig.valueStorageProvider = valueStorageProvider;
this.containerConfig.dsProvider = dsProvider;
@@ -241,151 +228,56 @@
pDbDialect = DBConstants.DB_DIALECT_GENERIC;
}
- String pDbDriver = null;
- String pDbUrl = null;
- String pDbUserName = null;
- String pDbPassword = null;
- try
- {
- pDbDriver = wsConfig.getContainer().getParameterValue(DB_DRIVER);
+ this.containerConfig.dbSourceName =
wsConfig.getContainer().getParameterValue(SOURCE_NAME);
- // username/passwd may not pesent
- try
- {
- pDbUserName = wsConfig.getContainer().getParameterValue(DB_USERNAME);
- pDbPassword = wsConfig.getContainer().getParameterValue(DB_PASSWORD);
- }
- catch (RepositoryConfigurationException e)
- {
- pDbUserName = pDbPassword = null;
- }
-
- pDbUrl = wsConfig.getContainer().getParameterValue(DB_URL); // last here!
- }
- catch (RepositoryConfigurationException e)
+ if (dsProvider == null)
{
- if (LOG.isTraceEnabled())
- {
- LOG.trace("An exception occurred: " + e.getMessage());
- }
+ 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.containerConfig.isManaged =
dsProvider.isManaged(containerConfig.dbSourceName);
- if (pDbUrl != null)
+ if (pDbDialect == DBConstants.DB_DIALECT_GENERIC)
{
- 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.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))
+ // try to detect via JDBC metadata
+ final DataSource ds = getDataSource();
+ Connection jdbcConn = null;
+ try
{
- // try to detect via JDBC metadata
- Connection jdbcConn = null;
- try
+ jdbcConn = SecurityHelper.doPrivilegedSQLExceptionAction(new
PrivilegedExceptionAction<Connection>()
{
- jdbcConn =
- containerConfig.dbUserName != null ?
DriverManager.getConnection(containerConfig.dbUrl,
- containerConfig.dbUserName, containerConfig.dbPassword) :
DriverManager
- .getConnection(containerConfig.dbUrl);
-
- this.containerConfig.dbDialect =
DialectDetecter.detect(jdbcConn.getMetaData());
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- finally
- {
- if (jdbcConn != null)
+ public Connection run() throws Exception
{
- try
- {
- jdbcConn.close();
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
+ return ds.getConnection();
}
- }
- }
- else
- {
- this.containerConfig.dbDialect = pDbDialect;
- }
- }
- else
- {
- this.containerConfig.dbDriver = null;
- this.containerConfig.dbUrl = null;
- this.containerConfig.dbUserName = null;
- this.containerConfig.dbPassword = null;
+ });
- String sn;
- try
- {
- sn = wsConfig.getContainer().getParameterValue(SOURCE_NAME);
+ this.containerConfig.dbDialect =
DialectDetecter.detect(jdbcConn.getMetaData());
}
- catch (RepositoryConfigurationException e)
+ catch (SQLException e)
{
- // for backward comp remove in rel.2.0
- sn = wsConfig.getContainer().getParameterValue("sourceName");
+ throw new RepositoryException(e);
}
- this.containerConfig.dbSourceName = sn;
- if (dsProvider == null)
+ finally
{
- 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.containerConfig.isManaged =
dsProvider.isManaged(containerConfig.dbSourceName);
-
- if (pDbDialect == DBConstants.DB_DIALECT_GENERIC)
- {
- // try to detect via JDBC metadata
- final DataSource ds = getDataSource();
- Connection jdbcConn = null;
- try
+ if (jdbcConn != null)
{
- jdbcConn = SecurityHelper.doPrivilegedSQLExceptionAction(new
PrivilegedExceptionAction<Connection>()
+ try
{
- public Connection run() throws Exception
- {
- return ds.getConnection();
- }
- });
-
- this.containerConfig.dbDialect =
DialectDetecter.detect(jdbcConn.getMetaData());
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- finally
- {
- if (jdbcConn != null)
+ jdbcConn.close();
+ }
+ catch (SQLException e)
{
- try
- {
- jdbcConn.close();
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
+ throw new RepositoryException(e);
}
}
}
- else
- {
- this.containerConfig.dbDialect = pDbDialect;
- }
}
+ else
+ {
+ this.containerConfig.dbDialect = pDbDialect;
+ }
LOG.info("Using a dialect '" + this.containerConfig.dbDialect +
"'");
// check is there DB_FORCE_QUERY_HINTS parameter - by default its enabled
@@ -429,7 +321,7 @@
this.containerConfig.swapCleaner = fileCleanerHolder.getFileCleaner();
this.containerConfig.initScriptPath =
- DBInitializerHelper.scriptPath(containerConfig.dbDialect,
containerConfig.dbStructureType.isSimpleTable());
+ DBInitializerHelper.scriptPath(containerConfig.dbDialect,
containerConfig.dbStructureType.isMultiDatabase());
initDatabase();
@@ -447,13 +339,7 @@
*/
protected GenericConnectionFactory defaultConnectionFactory() throws NamingException,
RepositoryException
{
- // by default
- if (containerConfig.dbSourceName != null)
- {
- return new GenericConnectionFactory(getDataSource(), containerConfig);
- }
-
- return new GenericConnectionFactory(containerConfig);
+ return new GenericConnectionFactory(getDataSource(), containerConfig);
}
/**
@@ -461,7 +347,7 @@
*
* @param sqlPath
* - path to SQL script (database creation script)
- * @return StorageDBInitializer instance
+ * @return DBInitializer instance
* @throws NamingException
* on JNDI error
* @throws RepositoryException
@@ -469,9 +355,9 @@
* @throws IOException
* on I/O error
*/
- protected StorageDBInitializer defaultDBInitializer() throws NamingException,
RepositoryException, IOException
+ protected DBInitializer defaultDBInitializer() throws NamingException,
RepositoryException, IOException
{
- return new StorageDBInitializer(this.connFactory.getJdbcConnection(),
containerConfig);
+ return new DBInitializer(this.connFactory.getJdbcConnection(), containerConfig);
}
/**
@@ -487,7 +373,8 @@
protected void checkIntegrity(WorkspaceEntry wsConfig, RepositoryEntry repConfig)
throws RepositoryConfigurationException
{
- JDBCDataContainerConfig.DatabaseStructureType dbType;
+ DatabaseStructureType dbType = getDatabaseType(wsConfig);
+
for (WorkspaceEntry wsEntry : repConfig.getWorkspaceEntries())
{
if (wsEntry.getName().equals(wsConfig.getName())
@@ -497,15 +384,13 @@
continue;
}
- if (!getDatabaseType(wsEntry).equals(getDatabaseType(wsConfig)))
+ if (!getDatabaseType(wsEntry).equals(dbType))
{
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));
+ + wsEntry.getName() + "=" + getDatabaseType(wsEntry) + "
and " + wsConfig.getName()
+ + "=" + dbType);
}
- dbType = getDatabaseType(wsConfig);
-
// source name
String wsSourceName = null;
String newWsSourceName = null;
@@ -524,7 +409,7 @@
if (wsSourceName != null && newWsSourceName != null)
{
- if (dbType.isSingleDatabase())
+ if (!dbType.isMultiDatabase() || dbType == DatabaseStructureType.ISOLATED)
{
if (!wsSourceName.equals(newWsSourceName))
{
@@ -536,50 +421,14 @@
{
if (wsSourceName.equals(newWsSourceName))
{
- throw new RepositoryConfigurationException("SourceName " +
wsSourceName + " alredy in use in "
+ throw new RepositoryConfigurationException("SourceName " +
wsSourceName + " already in use in "
+ wsEntry.getName() + ". SourceName must be different in "
+ dbType
+ "-database structure type. Check configuration for " +
wsConfig.getName());
}
}
+
continue;
}
-
- // db-url
- String wsUri = null;
- String newWsUri = null;
- try
- {
- wsUri = wsEntry.getContainer().getParameterValue("db-url");
- newWsUri = wsConfig.getContainer().getParameterValue("db-url");
- }
- catch (RepositoryConfigurationException e)
- {
- if (LOG.isTraceEnabled())
- {
- LOG.trace("An exception occurred: " + e.getMessage());
- }
- }
-
- if (wsUri != null && newWsUri != null)
- {
- if (dbType.isSingleDatabase())
- {
- if (!wsUri.equals(newWsUri))
- {
- throw new RepositoryConfigurationException("db-url must be equals
in " + dbType
- + "-database repository." + " Check " +
wsEntry.getName() + " and " + wsConfig.getName());
- }
- }
- else
- {
- if (wsUri.equals(newWsUri))
- {
- 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());
- }
- }
- }
}
}
@@ -595,21 +444,12 @@
*/
protected void initDatabase() throws NamingException, RepositoryException,
IOException
{
-
- StorageDBInitializer dbInitializer = null;
+ DBInitializer dbInitializer = null;
if (containerConfig.dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
{
LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is
experimental!");
- // sample of connection factory customization
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = defaultConnectionFactory();
- }
- else
- {
- this.connFactory = new OracleConnectionFactory(containerConfig);
- }
- // a particular db initializer may be configured here too
+
+ this.connFactory = defaultConnectionFactory();
dbInitializer = new OracleDBInitializer(this.connFactory.getJdbcConnection(),
containerConfig);
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_ORACLE)
@@ -634,15 +474,7 @@
+ " 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 (containerConfig.dbSourceName != null)
- {
- this.connFactory = new MySQLConnectionFactory(getDataSource(),
containerConfig);
- }
- else
- {
- this.connFactory = new MySQLConnectionFactory(containerConfig);
- }
-
+ this.connFactory = new MySQLConnectionFactory(getDataSource(),
containerConfig);
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_MSSQL)
@@ -678,14 +510,7 @@
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_HSQLDB)
{
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new HSQLDBConnectionFactory(getDataSource(),
containerConfig);
- }
- else
- {
- this.connFactory = new HSQLDBConnectionFactory(containerConfig);
- }
+ this.connFactory = new HSQLDBConnectionFactory(getDataSource(),
containerConfig);
dbInitializer = defaultDBInitializer();
}
else
@@ -910,15 +735,7 @@
{
JDBCWorkspaceDataContainer anotherJdbc = (JDBCWorkspaceDataContainer)another;
- if (getDbSourceName() != null)
- {
- // by jndi ds name
- return getDbSourceName().equals(anotherJdbc.getDbSourceName());
- }
-
- // by db connection params
- return getDbDriver().equals(anotherJdbc.getDbDriver()) &&
getDbUrl().equals(anotherJdbc.getDbUrl())
- && getDbUserName().equals(anotherJdbc.getDbUserName());
+ return getDbSourceName().equals(anotherJdbc.getDbSourceName());
}
return false;
@@ -935,36 +752,6 @@
}
/**
- * Used in <code>equals()</code>.
- *
- * @return JDBC driver
- */
- protected String getDbDriver()
- {
- return containerConfig.dbDriver;
- }
-
- /**
- * Used in <code>equals()</code>.
- *
- * @return Database URL
- */
- protected String getDbUrl()
- {
- return containerConfig.dbUrl;
- }
-
- /**
- * Used in <code>equals()</code>.
- *
- * @return Database username
- */
- protected String getDbUserName()
- {
- return containerConfig.dbUserName;
- }
-
- /**
* {@inheritDoc}
*/
public boolean isCheckSNSNewConnection()
@@ -1025,27 +812,33 @@
"JDBCWorkspaceDataContainer.info")));
backupInfo.writeString(containerConfig.containerName);
- backupInfo.writeBoolean(containerConfig.multiDb);
+ backupInfo.writeString(containerConfig.dbStructureType.toString());
Map<String, String> scripts = new HashMap<String, String>();
- if (containerConfig.multiDb)
+ String itemTable = DBInitializerHelper.getItemTableName(containerConfig);
+ String valueTable = DBInitializerHelper.getValueTableName(containerConfig);
+ String refTable = DBInitializerHelper.getRefTableName(containerConfig);
+
+ backupInfo.writeString(itemTable);
+ backupInfo.writeString(valueTable);
+ backupInfo.writeString(refTable);
+
+ if (containerConfig.dbStructureType.isMultiDatabase())
{
- scripts.put("JCR_MITEM", "select * from JCR_MITEM where
JCR_MITEM.NAME <> '" + Constants.ROOT_PARENT_NAME
- + "'");
- scripts.put("JCR_MVALUE", "select * from JCR_MVALUE");
- scripts.put("JCR_MREF", "select * from JCR_MREF");
+ scripts
+ .put(itemTable, "select * from " + itemTable + " where NAME
<> '" + Constants.ROOT_PARENT_NAME + "'");
+ scripts.put(valueTable, "select * from " + valueTable);
+ scripts.put(refTable, "select * from " + refTable);
}
else
{
- 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='"
- + 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='"
- + containerConfig.containerName + "'");
+ scripts.put(itemTable, "select * from " + itemTable + " where
CONTAINER_NAME='"
+ + containerConfig.containerName + "'");
+ scripts.put(valueTable, "select V.* from " + valueTable + " V,
" + itemTable
+ + " I where I.ID=V.PROPERTY_ID and I.CONTAINER_NAME='" +
containerConfig.containerName + "'");
+ scripts.put(refTable, "select R.* from " + refTable + " R,
" + itemTable
+ + " I where I.ID=R.PROPERTY_ID and I.CONTAINER_NAME='" +
containerConfig.containerName + "'");
}
// using existing DataSource to get a JDBC Connection.
@@ -1149,24 +942,24 @@
"JDBCWorkspaceDataContainer.info")));
String srcContainerName = backupInfo.readString();
- boolean srcMultiDb = backupInfo.readBoolean();
+ DatabaseStructureType dbType =
DatabaseStructureType.valueOf(backupInfo.readString());
Map<String, RestoreTableRule> tables = new LinkedHashMap<String,
RestoreTableRule>();
// ITEM table
- String dstTableName = "JCR_" + (containerConfig.multiDb ?
"M" : "S") + "ITEM";
- String srcTableName = "JCR_" + (srcMultiDb ? "M" :
"S") + "ITEM";
+ String dstTableName = DBInitializerHelper.getItemTableName(containerConfig);
+ String srcTableName = backupInfo.readString();
RestoreTableRule restoreTableRule = new RestoreTableRule();
restoreTableRule.setSrcContainerName(srcContainerName);
- restoreTableRule.setSrcMultiDb(srcMultiDb);
+ restoreTableRule.setSrcMultiDb(dbType.isMultiDatabase());
restoreTableRule.setDstContainerName(containerConfig.containerName);
- restoreTableRule.setDstMultiDb(containerConfig.multiDb);
+
restoreTableRule.setDstMultiDb(containerConfig.dbStructureType.isMultiDatabase());
restoreTableRule.setSrcTableName(srcTableName);
if (containerConfig.multiDb)
{
- if (!srcMultiDb)
+ if (!dbType.isMultiDatabase())
{
// CONTAINER_NAME column index
restoreTableRule.setDeleteColumnIndex(4);
@@ -1180,7 +973,7 @@
}
else
{
- if (srcMultiDb)
+ if (dbType.isMultiDatabase())
{
// CONTAINER_NAME column index
restoreTableRule.setNewColumnIndex(4);
@@ -1206,20 +999,20 @@
tables.put(dstTableName, restoreTableRule);
// VALUE table
- dstTableName = "JCR_" + (containerConfig.multiDb ? "M" :
"S") + "VALUE";
- srcTableName = "JCR_" + (srcMultiDb ? "M" : "S") +
"VALUE";
+ dstTableName = DBInitializerHelper.getValueTableName(containerConfig);
+ srcTableName = backupInfo.readString();
restoreTableRule = new RestoreTableRule();
restoreTableRule.setSrcContainerName(srcContainerName);
- restoreTableRule.setSrcMultiDb(srcMultiDb);
+ restoreTableRule.setSrcMultiDb(dbType.isMultiDatabase());
restoreTableRule.setDstContainerName(containerConfig.containerName);
- restoreTableRule.setDstMultiDb(containerConfig.multiDb);
+
restoreTableRule.setDstMultiDb(containerConfig.dbStructureType.isMultiDatabase());
restoreTableRule.setSrcTableName(srcTableName);
// auto increment ID column
restoreTableRule.setSkipColumnIndex(0);
- if (!containerConfig.multiDb || !srcMultiDb)
+ if (!containerConfig.dbStructureType.isMultiDatabase() ||
!dbType.isMultiDatabase())
{
// PROPERTY_ID column index
Set<Integer> convertColumnIndex = new HashSet<Integer>();
@@ -1229,17 +1022,17 @@
tables.put(dstTableName, restoreTableRule);
// REF tables
- dstTableName = "JCR_" + (containerConfig.multiDb ? "M" :
"S") + "REF";
- srcTableName = "JCR_" + (srcMultiDb ? "M" : "S") +
"REF";
+ dstTableName = DBInitializerHelper.getRefTableName(containerConfig);
+ srcTableName = backupInfo.readString();
restoreTableRule = new RestoreTableRule();
restoreTableRule.setSrcContainerName(srcContainerName);
- restoreTableRule.setSrcMultiDb(srcMultiDb);
+ restoreTableRule.setSrcMultiDb(dbType.isMultiDatabase());
restoreTableRule.setDstContainerName(containerConfig.containerName);
- restoreTableRule.setDstMultiDb(containerConfig.multiDb);
+
restoreTableRule.setDstMultiDb(containerConfig.dbStructureType.isMultiDatabase());
restoreTableRule.setSrcTableName(srcTableName);
- if (!containerConfig.multiDb || !srcMultiDb)
+ if (!containerConfig.dbStructureType.isMultiDatabase() ||
!dbType.isMultiDatabase())
{
// NODE_ID and PROPERTY_ID column indexes
Set<Integer> convertColumnIndex = new HashSet<Integer>();
@@ -1420,12 +1213,9 @@
}
/**
- * @param wsConfig
- * @return
- * @throws RepositoryConfigurationException
+ * Returns {@link DatabaseStructureType} based on workspace configuration.
*/
- public static JDBCDataContainerConfig.DatabaseStructureType
getDatabaseType(WorkspaceEntry wsConfig)
- throws RepositoryConfigurationException
+ public static DatabaseStructureType getDatabaseType(WorkspaceEntry wsConfig) throws
RepositoryConfigurationException
{
try
{
@@ -1445,4 +1235,13 @@
return JDBCDataContainerConfig.DatabaseStructureType.valueOf(dbStructureType);
}
}
+
+ /**
+ * Returns value of {@link #DB_TABLENAME_SUFFIX} parameter from workspace
configuration.
+ */
+ public static String getDBTableSuffix(WorkspaceEntry wsConfig)
+ {
+ return wsConfig.getContainer()
+ .getParameterValue(JDBCWorkspaceDataContainer.DB_TABLENAME_SUFFIX,
wsConfig.getName()).toUpperCase();
+ }
}
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-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -40,9 +40,9 @@
import org.exoplatform.services.jcr.impl.core.lock.LockTableHandler;
import org.exoplatform.services.jcr.impl.core.lock.LockTableHandlerFactory;
import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeDataManagerImpl;
-import
org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig.DatabaseStructureType;
import org.exoplatform.services.jcr.impl.storage.value.ValueDataNotFoundException;
import org.exoplatform.services.jcr.impl.storage.value.ValueStorageNotFoundException;
+import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.jcr.storage.value.ValueIOChannel;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
@@ -472,68 +472,64 @@
private void initInspectionQueries()
{
- String itemTableSuffix =
getItemTableSuffix(jdbcDataContainer.containerConfig.dbStructureType);
- String valueTableSuffix =
getValueTableSuffix(jdbcDataContainer.containerConfig.dbStructureType);
- String referenceTableSuffix =
getReferenceTableSuffix(jdbcDataContainer.containerConfig.dbStructureType);
+ String itemTable =
DBInitializerHelper.getItemTableName(jdbcDataContainer.containerConfig);
+ String valueTable =
DBInitializerHelper.getValueTableName(jdbcDataContainer.containerConfig);
+ String refTable =
DBInitializerHelper.getRefTableName(jdbcDataContainer.containerConfig);
boolean singleDatabase =
jdbcDataContainer.containerConfig.dbStructureType ==
JDBCDataContainerConfig.DatabaseStructureType.SINGLE;
vsInspectionQuery =
- new InspectionQuery(singleDatabase ? "select V.PROPERTY_ID, V.ORDER_NUM,
V.STORAGE_DESC from JCR_"
- + valueTableSuffix + " V, JCR_" + itemTableSuffix + " I"
+ " where I.CONTAINER_NAME='"
- + jdbcDataContainer.containerConfig.containerName
+ new InspectionQuery(singleDatabase ? "select V.PROPERTY_ID, V.ORDER_NUM,
V.STORAGE_DESC from " + valueTable
+ + " V, " + itemTable + " I" + " where
I.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
+ "' and V.PROPERTY_ID = I.ID and STORAGE_DESC is not null"
- : "select PROPERTY_ID, ORDER_NUM, STORAGE_DESC from JCR_" +
valueTableSuffix
- + " where 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());
+ : "select PROPERTY_ID, ORDER_NUM, STORAGE_DESC from " + valueTable
+ " where 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(singleDatabase ? "select distinct PARENT_ID from
JCR_" + itemTableSuffix
- + " WHERE CONTAINER_NAME='" +
jdbcDataContainer.containerConfig.containerName + "'"
+ new InspectionQuery(singleDatabase ? "select distinct PARENT_ID from "
+ itemTable + " 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')" :
"select distinct PARENT_ID from JCR_"
- + itemTableSuffix + " where I_CLASS=2 AND"
+ + " OR
NAME='[http://www.jcp.org/jcr/1.0]lockIsDeep')" :
"select distinct PARENT_ID from " + itemTable
+ + " where 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(singleDatabase ? "select * from
JCR_" + itemTableSuffix
+ itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from
" + itemTable
+ " I where I.CONTAINER_NAME='" +
jdbcDataContainer.containerConfig.containerName
- + "' and NOT EXISTS(select * from JCR_" + itemTableSuffix + "
P where P.ID = I.PARENT_ID)"
- : "select * from JCR_" + itemTableSuffix + " I where NOT
EXISTS(select * from JCR_" + itemTableSuffix
- + " 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())));
+ + "' and NOT EXISTS(select * from " + itemTable + " P where
P.ID = I.PARENT_ID)" : "select * from "
+ + itemTable + " I where NOT EXISTS(select * from " + itemTable +
" 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())));
- itemsInspectionQuery.add(new
InspectionQueryFilteredMultivaluedProperties(singleDatabase ? "select * from
JCR_"
- + itemTableSuffix + " P where P.CONTAINER_NAME='" +
jdbcDataContainer.containerConfig.containerName
- + "' and P.I_CLASS=2" + " and P.P_MULTIVALUED=? and NOT
EXISTS( select * from JCR_" + valueTableSuffix
- + " V where V.PROPERTY_ID=P.ID)" : "select * from JCR_" +
itemTableSuffix
- + " P where P.I_CLASS=2 and P.P_MULTIVALUED=? and NOT EXISTS( select * from
JCR_" + valueTableSuffix + " V "
+ itemsInspectionQuery.add(new
InspectionQueryFilteredMultivaluedProperties(singleDatabase ? "select * from "
+ + itemTable + " P where P.CONTAINER_NAME='" +
jdbcDataContainer.containerConfig.containerName
+ + "' and P.I_CLASS=2" + " and P.P_MULTIVALUED=? and NOT
EXISTS( select * from " + valueTable
+ + " V where V.PROPERTY_ID=P.ID)" : "select * from " +
itemTable
+ + " P where P.I_CLASS=2 and P.P_MULTIVALUED=? and NOT EXISTS( select * from
" + valueTable + " 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(singleDatabase ? "select * from
JCR_" + itemTableSuffix
+ itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from
" + itemTable
+ " N where N.CONTAINER_NAME='" +
jdbcDataContainer.containerConfig.containerName
- + "' and N.I_CLASS=1 and NOT EXISTS (select * from JCR_" +
itemTableSuffix + " P "
+ + "' and N.I_CLASS=1 and NOT EXISTS (select * from " + itemTable +
" 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.containerConfig.containerName + "')" : "select * from
JCR_"
- + itemTableSuffix + " N where N.I_CLASS=1 and NOT EXISTS " +
"(select * from JCR_" + itemTableSuffix
+ + "and P.CONTAINER_NAME='" +
jdbcDataContainer.containerConfig.containerName + "')" : "select * from
"
+ + itemTable + " N where N.I_CLASS=1 and NOT EXISTS " + "(select *
from " + itemTable
+ " P where P.I_CLASS=2 and P.PARENT_ID=N.ID " + "and
P.NAME='[http://www.jcp.org/jcr/1.0]primaryType')",
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(singleDatabase ? "select * from
JCR_" + valueTableSuffix
- + " V where NOT EXISTS(select * from JCR_" + itemTableSuffix + "
P "
- + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)" : "select * from
JCR_" + valueTableSuffix
- + " V where NOT EXISTS(select * from JCR_" + itemTableSuffix + "
P "
- + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)", new
String[]{DBConstants.COLUMN_ID,
+ itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from
" + valueTable
+ + " V where NOT EXISTS(select * from " + itemTable + " P " +
"where V.PROPERTY_ID = P.ID and P.I_CLASS=2)"
+ : "select * from " + valueTable + " V where NOT EXISTS(select *
from " + itemTable + " 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.containerConfig.containerName,
jdbcDataContainer.containerConfig.multiDb)));
@@ -543,107 +539,59 @@
if
(jdbcDataContainer.containerConfig.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE))
{
statement =
- singleDatabase ? "select V.* from JCR_" + valueTableSuffix + "
V, JCR_" + itemTableSuffix
+ singleDatabase ? "select V.* from " + valueTable + " V, "
+ itemTable
+ " I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
+ jdbcDataContainer.containerConfig.containerName
- + "' AND ((STORAGE_DESC is not null and not DATA like
null))" : "select * from JCR_" + valueTableSuffix
+ + "' AND ((STORAGE_DESC is not null and not DATA like
null))" : "select * from " + valueTable
+ " where (STORAGE_DESC is not null and not DATA like null)";
}
else if
(jdbcDataContainer.containerConfig.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLE)
||
jdbcDataContainer.containerConfig.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLEOCI))
{
statement =
- singleDatabase ? "select V.* from JCR_" + valueTableSuffix + "
V, JCR_" + itemTableSuffix
+ singleDatabase ? "select V.* from " + valueTable + " V, "
+ itemTable
+ " I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
+ jdbcDataContainer.containerConfig.containerName
- + "' AND (STORAGE_DESC is not null and DATA is not null)" :
"select * from JCR_" + valueTableSuffix
+ + "' AND (STORAGE_DESC is not null and DATA is not null)" :
"select * from " + valueTable
+ " where (STORAGE_DESC is not null and DATA is not null)";
}
else
{
statement =
- singleDatabase ? "select V.* from JCR_" + valueTableSuffix + "
V, JCR_" + itemTableSuffix
+ singleDatabase ? "select V.* from " + valueTable + " V, "
+ itemTable
+ " I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
+ jdbcDataContainer.containerConfig.containerName
- + "' AND ((STORAGE_DESC is not null and DATA is not null))"
: "select * from JCR_" + valueTableSuffix
+ + "' AND ((STORAGE_DESC is not null and DATA is not null))"
: "select * from " + valueTable
+ " where (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(singleDatabase ? "select * from
JCR_" + itemTableSuffix
+ itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from
" + itemTable
+ " I where I.ID = I.PARENT_ID and I.CONTAINER_NAME='" +
jdbcDataContainer.containerConfig.containerName
- + "' and I.NAME <> '" + Constants.ROOT_PARENT_NAME +
"'" : "select * from JCR_" + itemTableSuffix
+ + "' and I.NAME <> '" + Constants.ROOT_PARENT_NAME +
"'" : "select * from " + itemTable
+ " I where I.ID = I.PARENT_ID 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(singleDatabase ? "select * from
JCR_" + itemTableSuffix
+ itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from
" + itemTable
+ " I where I.CONTAINER_NAME='" +
jdbcDataContainer.containerConfig.containerName
- + "' and EXISTS (select * from JCR_" + itemTableSuffix + " J
WHERE I.CONTAINER_NAME = J.CONTAINER_NAME and"
+ + "' and EXISTS (select * from " + itemTable + " 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)" : "select * from JCR_" +
itemTableSuffix
- + " I where EXISTS (select * from JCR_" + itemTableSuffix + "
J"
+ + " and I.VERSION != J.VERSION)" : "select * from " +
itemTable + " I where EXISTS (select * from "
+ + itemTable + " 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)", new String[]{DBConstants.COLUMN_ID,
DBConstants.COLUMN_PARENTID,
DBConstants.COLUMN_NAME, DBConstants.COLUMN_VERSION, DBConstants.COLUMN_CLASS,
DBConstants.COLUMN_INDEX},
"Several versions of same item.", new
EarlierVersionsRemover(jdbcDataContainer.getConnectionFactory())));
- itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from
JCR_" + itemTableSuffix + " P, JCR_"
- + valueTableSuffix + " V where P.ID=V.PROPERTY_ID and
P.CONTAINER_NAME='"
- + jdbcDataContainer.containerConfig.containerName + "' and P.P_TYPE=9
and NOT EXISTS (select * from JCR_"
- + referenceTableSuffix + " R where P.ID=R.PROPERTY_ID)" : "select
* from JCR_" + itemTableSuffix + " P, JCR_"
- + valueTableSuffix + " V where P.ID=V.PROPERTY_ID and P.P_TYPE=9 and NOT
EXISTS " + "(select * from JCR_"
- + referenceTableSuffix + " 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)));
+ itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from
" + itemTable + " P, " + valueTable
+ + " V where P.ID=V.PROPERTY_ID and P.CONTAINER_NAME='" +
jdbcDataContainer.containerConfig.containerName
+ + "' and P.P_TYPE=9 and NOT EXISTS (select * from " + refTable +
" R where P.ID=R.PROPERTY_ID)"
+ : "select * from " + itemTable + " P, " + valueTable
+ + " V where P.ID=V.PROPERTY_ID and P.P_TYPE=9 and NOT EXISTS " +
"(select * from " + refTable
+ + " 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)));
}
-
- private String getItemTableSuffix(DatabaseStructureType dbStructureType)
- {
- if (dbStructureType == DatabaseStructureType.MULTI)
- {
- return "MITEM";
- }
- else if (dbStructureType == DatabaseStructureType.SINGLE)
- {
- return "SITEM";
- }
- else
- {
- return "I" + jdbcDataContainer.containerConfig.dbTableSuffix;
- }
- }
-
- private String getValueTableSuffix(DatabaseStructureType dbStructureType)
- {
- if (dbStructureType == DatabaseStructureType.MULTI)
- {
- return "MVALUE";
- }
- else if (dbStructureType == DatabaseStructureType.SINGLE)
- {
- return "SVALUE";
- }
- else
- {
- return "V" + jdbcDataContainer.containerConfig.dbTableSuffix;
- }
- }
-
- private String getReferenceTableSuffix(DatabaseStructureType dbStructureType)
- {
- if (dbStructureType == DatabaseStructureType.MULTI)
- {
- return "MREF";
- }
- else if (dbStructureType == DatabaseStructureType.SINGLE)
- {
- return "SREF";
- }
- else
- {
- return "R" + jdbcDataContainer.containerConfig.dbTableSuffix;
- }
- }
}
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-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -18,14 +18,12 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.db;
-import org.exoplatform.commons.utils.ClassLoading;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import java.sql.Connection;
-import java.sql.DriverManager;
import java.sql.SQLException;
import javax.jcr.RepositoryException;
@@ -57,31 +55,6 @@
}
/**
- * GenericConnectionFactory constructor with dbDriver class validation
- */
- public GenericConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
- {
- this(null, containerConfig);
-
- try
- {
- ClassLoading.forName(this.containerConfig.dbDriver, this).newInstance();
- }
- catch (InstantiationException e)
- {
- throw new RepositoryException(e);
- }
- catch (IllegalAccessException e)
- {
- throw new RepositoryException(e);
- }
- catch (ClassNotFoundException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
* {@inheritDoc}
*/
public WorkspaceStorageConnection openConnection() throws RepositoryException
@@ -97,7 +70,7 @@
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new MultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
@@ -118,10 +91,8 @@
{
try
{
- 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));
+ Connection conn = dbDataSource.getConnection();
+
if (readOnly)
{
// set this feature only if it asked
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-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBConnectionFactory.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -44,22 +44,13 @@
}
/**
- * HSQLDBConnectionFactory constructor.
- */
- public HSQLDBConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
- {
-
- super(containerConfig);
- }
-
- /**
* {@inheritDoc}
*/
public WorkspaceStorageConnection openConnection(boolean readOnly) throws
RepositoryException
{
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new HSQLDBMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
Deleted:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java.orig
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java.orig 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java.orig 2012-03-14
13:28:03 UTC (rev 5863)
@@ -1,679 +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.db;
-
-import org.exoplatform.services.jcr.datamodel.NodeData;
-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.dataflow.ValueDataConvertor;
-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;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.List;
-
-/**
- * Single database connection implementation.
- *
- * Created by The eXo Platform SAS. </br>
- *
- * @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady
- * Azarenkov</a>
- * @version $Id: MultiDbJDBCConnection.java 20950 2008-10-06 14:23:07Z
- * pnedonosko $
- */
-
-public class MultiDbJDBCConnection extends JDBCStorageConnection
-{
-
- /**
- * 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
- */
- public MultiDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
- throws SQLException
- {
-
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getIdentifier(final String internalId)
- {
- return internalId;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getInternalId(final String identifier)
- {
- return identifier;
- }
-
- /**
- * {@inheritDoc}
- */
- @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_NAME =
- "select * from JCR_MITEM" + " 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"
- + " 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";
-
- FIND_VALUES_BY_PROPERTYID =
- "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_MVALUE where
PROPERTY_ID=? order by ORDER_NUM";
-
- FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from
JCR_MVALUE where PROPERTY_ID=?";
-
- FIND_VALUE_BY_PROPERTYID_OREDERNUMB =
- "select DATA, STORAGE_DESC from JCR_MVALUE 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_LAST_ORDER_NUMBER_BY_PARENTID =
- "select count(*), max(N_ORDER_NUM) from JCR_MITEM 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_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where
I_CLASS=2 and PARENT_ID=?" + " order by ID";
-
- FIND_LOWEST_PROPERTY_VERSIONS =
- "select max(VERSION) as MAX_VERSION, PARENT_ID, NAME, I_CLASS, I_INDEX from
JCR_SITEM WHERE I_CLASS=2"
- + " GROUP BY PARENT_ID, NAME, I_CLASS, I_INDEX HAVING count(VERSION)
> 1";
-
- INSERT_NODE =
- "insert into JCR_MITEM(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(?,?,?,?,"
- + 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(?,?,?)";
-
- RENAME_NODE = "update JCR_MITEM 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=?";
-
- 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=?";
-
- FIND_NODES_COUNT = "select count(*) from JCR_MITEM I where I.I_CLASS=1";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(3, data.getQPath().getName().getAsString());
- insertNode.setInt(4, data.getPersistedVersion());
- insertNode.setInt(5, data.getQPath().getIndex());
- insertNode.setInt(6, data.getOrderNumber());
- return insertNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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());
- insertProperty.setString(3, data.getQPath().getName().getAsString());
- insertProperty.setInt(4, data.getPersistedVersion());
- insertProperty.setInt(5, data.getQPath().getIndex());
- insertProperty.setInt(6, data.getType());
- insertProperty.setBoolean(7, data.isMultiValued());
-
- return insertProperty.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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;
- for (int i = 0; i < values.size(); i++)
- {
- ValueData vdata = values.get(i);
- String refNodeIdentifier = ValueDataConvertor.readString(vdata);
-
- insertReference.setString(1, refNodeIdentifier);
- insertReference.setString(2, data.getIdentifier());
- insertReference.setInt(3, i);
- added += insertReference.executeUpdate();
- }
-
- return added;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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);
- updateNode.setInt(3, orderNumb);
- updateNode.setString(4, identifier);
- return updateNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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);
- updateProperty.setString(3, identifier);
- return updateProperty.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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);
- findItemByName.setInt(3, index);
- return findItemByName.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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);
- return findPropertyByName.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- protected ResultSet findChildNodesByParentIdentifier(String parentCid, int
fromOrderNum, int toOrderNum)
- throws SQLException
- {
- throw new UnsupportedOperationException("findChildNodesByParentIdentifier is
not supported for old queries");
- }
-
- // -------- values processing ------------
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addValueData(String cid, int orderNumber, InputStream stream, int
streamLength, String storageDesc)
- throws SQLException
- {
-
- if (insertValue == null)
- insertValue = dbConnection.prepareStatement(INSERT_VALUE);
- else
- insertValue.clearParameters();
-
- if (stream == null)
- {
- // [PN] store vd reference to external storage etc.
- insertValue.setNull(1, Types.BINARY);
- insertValue.setString(4, storageDesc);
- }
- else
- {
- insertValue.setBinaryStream(1, stream, streamLength);
- insertValue.setNull(4, Types.VARCHAR);
- }
-
- insertValue.setInt(2, orderNumber);
- insertValue.setString(3, cid);
- return insertValue.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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);
- return findValueByPropertyIdOrderNumber.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(2, data.getQPath().getName().getAsString());
- renameNode.setInt(3, data.getPersistedVersion());
- renameNode.setInt(4, data.getQPath().getIndex());
- renameNode.setInt(5, data.getOrderNumber());
- renameNode.setString(6, data.getIdentifier());
- return renameNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findNodesAndProperties(String lastNodeId, int offset, int limit)
throws SQLException
- {
- throw new UnsupportedOperationException(
- "The method findNodesAndProperties is not supported for this type of
connection use the complex queries instead");
- }
-
- /**
- * {@inheritDoc}
- */
- protected void deleteLockProperties() throws SQLException
- {
- PreparedStatement removeValuesStatement = null;
- PreparedStatement removeItemsStatement = null;
-
- 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"
- + " 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'"
- + " OR NAME =
'[http://www.jcp.org/jcr/1.0]lockOwner'");
-
- removeValuesStatement.executeUpdate();
- removeItemsStatement.executeUpdate();
- }
- finally
- {
- if (removeValuesStatement != null)
- {
- try
- {
- removeValuesStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
-
- if (removeItemsStatement != null)
- {
- try
- {
- removeItemsStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findNodesCount() throws SQLException
- {
- if (findNodesCount == null)
- {
- findNodesCount = dbConnection.prepareStatement(FIND_NODES_COUNT);
- }
- return findNodesCount.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- protected void deleteLockProperties(String nodeIdentifier) throws SQLException
- {
- PreparedStatement removeValuesStatement = null;
- PreparedStatement removeItemsStatement = null;
-
- 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"
- + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'))");
-
- removeItemsStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_MITEM WHERE 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, getInternalId(nodeIdentifier));
- removeItemsStatement.setString(1, getInternalId(nodeIdentifier));
-
- removeValuesStatement.executeUpdate();
- removeItemsStatement.executeUpdate();
- }
- finally
- {
- if (removeValuesStatement != null)
- {
- try
- {
- removeValuesStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
-
- if (removeItemsStatement != null)
- {
- try
- {
- removeItemsStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
- }
- }
-
-}
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-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLConnectionFactory.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -38,15 +38,6 @@
{
/**
- * MySQLConnectionFactory constructor.
- */
- public MySQLConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
- {
-
- super(containerConfig);
- }
-
- /**
* MySQLConnectionFactory constructor.
*/
public MySQLConnectionFactory(DataSource dbDataSource, JDBCDataContainerConfig
containerConfig)
@@ -63,7 +54,7 @@
{
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new MySQLMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
Deleted:
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-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OracleConnectionFactory.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -1,194 +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.db;
-
-import org.exoplatform.commons.utils.ClassLoading;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.sql.Connection;
-import java.util.Properties;
-
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS
- *
- * 23.03.2007
- *
- * Access Oracle implicit connection caching and pooling stuff using reflection to
prevent Maven
- * dependecies on ora drivers from POM.
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
- * @version $Id: OracleConnectionFactory.java 34801 2009-07-31 15:44:50Z dkatayev $
- */
-public class OracleConnectionFactory extends GenericConnectionFactory
-{
-
- public static int CONNCACHE_MAX_LIMIT = 25;
-
- public static int CONNCACHE_MIN_LIMIT = 2;
-
- public static int CONNCACHE_INACTIVITY_TIMEOUT = 3600;
-
- public static int CONNCACHE_ABADONDED_TIMEOUT = 1800;
-
- protected final Object ociDataSource;
-
- /**
- * OracleConnectionFactory constructor. For CLI interface ONLY!
- */
- public OracleConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
- {
-
- // ;D:\Devel\oracle_instantclient_10_2\;C:\oracle\ora92\bin;
-
- /*
- * ERROR: if no oci in path and oci url requested Error:
- * java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
- *
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
- * at
- *
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl
- * .java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at
- * ocipool.ConnPoolAppl.main(ConnPoolAppl.java:58) Caused by:
java.lang.UnsatisfiedLinkError: no
- * ocijdbc10 in java.library.path at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
- * ---------------------------------------------------------------------------
ERROR: if thin
- * url used and trying obtain oci data source
java.lang.reflect.InvocationTargetException at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
- *
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
- * at
- *
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl
- * .java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at
- * ocipool.ConnPoolAppl.main(ConnPoolAppl.java:58) Caused by:
java.lang.ClassCastException:
- * oracle.jdbc.driver.T4CConnection at
- * oracle.jdbc.pool.OracleOCIConnectionPool.createConnectionPool
- * (OracleOCIConnectionPool.java:893)
- */
-
- super(containerConfig);
-
- Object cds = null;
- try
- {
- Class<?> cdsClass =
ClassLoading.loadClass("oracle.jdbc.pool.OracleDataSource", this);
- Constructor<?> cdsConstructor = cdsClass.getConstructor(new Class[]{});
- cds = cdsConstructor.newInstance(new Object[]{});
-
- // set cache properties
- Properties prop = new java.util.Properties();
- prop.setProperty("InitialLimit",
String.valueOf(CONNCACHE_MIN_LIMIT));
- prop.setProperty("MinLimit", String.valueOf(CONNCACHE_MIN_LIMIT));
- prop.setProperty("MaxLimit", String.valueOf(CONNCACHE_MAX_LIMIT));
- prop.setProperty("InactivityTimeout",
String.valueOf(CONNCACHE_INACTIVITY_TIMEOUT));
- prop.setProperty("AbandonedConnectionTimeout",
String.valueOf(CONNCACHE_ABADONDED_TIMEOUT));
-
- Method setURL = cds.getClass().getMethod("setURL", new
Class[]{String.class});
- setURL.invoke(cds, new Object[]{this.containerConfig.dbUrl});
-
- Method setUser = cds.getClass().getMethod("setUser", new
Class[]{String.class});
- setUser.invoke(cds, new Object[]{this.containerConfig.dbUserName});
-
- Method setPassword = cds.getClass().getMethod("setPassword", new
Class[]{String.class});
- setPassword.invoke(cds, new Object[]{this.containerConfig.dbPassword});
-
- Method setConnectionCachingEnabled =
- cds.getClass().getMethod("setConnectionCachingEnabled", new
Class[]{boolean.class});
- setConnectionCachingEnabled.invoke(cds, new Object[]{true});
-
- Method setConnectionCacheProperties =
- cds.getClass().getMethod("setConnectionCacheProperties", new
Class[]{Properties.class});
- setConnectionCacheProperties.invoke(cds, new Object[]{prop});
-
- Method setConnectionCacheName =
cds.getClass().getMethod("setConnectionCacheName", new Class[]{String.class});
- 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);
- 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
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Connection getJdbcConnection(boolean readOnly) throws RepositoryException
- {
- if (ociDataSource != null)
- {
- try
- {
- Connection conn = getCachedConnection();
-
- if (readOnly)
- {
- // set this feature only if it asked
- conn.setReadOnly(true);
- }
-
- return conn;
- }
- catch (Throwable e)
- {
- throw new RepositoryException("Oracle OCI cached connection open error
" + e, e);
- }
- }
-
- return super.getJdbcConnection(readOnly);
- }
-
- /**
- * Get CachedConnection.
- *
- * @return
- * @throws NoSuchMethodException
- * @throws IllegalArgumentException
- * @throws IllegalAccessException
- * @throws InvocationTargetException
- */
- protected Connection getCachedConnection() throws NoSuchMethodException,
IllegalArgumentException,
- IllegalAccessException, InvocationTargetException
- {
-
- // NOTE: ociDataSource - actually instance of javax.sql.DataSource
- Method getConnection =
ociDataSource.getClass().getMethod("getConnection", new Class[]{});
- Connection conn = (Connection)getConnection.invoke(ociDataSource, new Object[]{});
-
- return conn;
- }
-}
Deleted:
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-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OraclePoolConnectionFactory.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -1,227 +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.db;
-
-import org.exoplatform.commons.utils.ClassLoading;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.sql.Connection;
-import java.util.Properties;
-
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS
- *
- * 16.03.2007
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
- * @version $Id: OraclePoolConnectionFactory.java 34801 2009-07-31 15:44:50Z dkatayev $
- */
-public class OraclePoolConnectionFactory extends GenericConnectionFactory
-{
-
- public static int CONNPOOL_MAX_LIMIT = 20;
-
- public static int CONNPOOL_MIN_LIMIT = 2;
-
- public static int CONNPOOL_INCREMENT = 1;
-
- protected final Object ociPool;
-
- /**
- * OraclePoolConnectionFactory constructor. For CLI interface ONLY!
- */
- public OraclePoolConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
- {
-
- // ;D:\Devel\oracle_instantclient_10_2\;C:\oracle\ora92\bin;
-
- /*
- * ERROR: if no oci in path and oci url requested Error:
- * java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
- *
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
- * at
- *
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl
- * .java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at
- * ocipool.ConnPoolAppl.main(ConnPoolAppl.java:58) Caused by:
java.lang.UnsatisfiedLinkError: no
- * ocijdbc10 in java.library.path at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
- * ---------------------------------------------------------------------------
ERROR: if thin
- * url used and trying obtain oci data source
java.lang.reflect.InvocationTargetException at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
- *
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
- * at
- *
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl
- * .java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at
- * ocipool.ConnPoolAppl.main(ConnPoolAppl.java:58) Caused by:
java.lang.ClassCastException:
- * oracle.jdbc.driver.T4CConnection at
- * oracle.jdbc.pool.OracleOCIConnectionPool.createConnectionPool
- * (OracleOCIConnectionPool.java:893)
- */
-
- super(containerConfig);
-
- Object cpool = null;
- try
- {
- Class<?> cpoolClass =
ClassLoading.loadClass("oracle.jdbc.pool.OracleOCIConnectionPool", this);
- Constructor<?> cpoolConstructor =
- cpoolClass.getConstructor(new Class[]{String.class, String.class,
String.class, Properties.class});
-
- 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});
- }
- catch (Throwable e)
- {
- cpool = null;
- 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;
-
- // configure using CONNPOOL_MAX_LIMIT, CONNPOOL_MIN_LIMIT, CONNPOOL_INCREMENT
- try
- {
- reconfigure();
- displayPoolConfig();
- }
- 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);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Connection getJdbcConnection(boolean readOnly) throws RepositoryException
- {
- if (ociPool != null)
- {
- try
- {
- Connection conn = getPoolConnection();
-
- if (readOnly)
- {
- // set this feature only if it asked
- conn.setReadOnly(true);
- }
-
- return conn;
- }
- catch (Throwable e)
- {
- throw new RepositoryException("Oracle OCI pool connection open error
" + e, e);
- }
- }
-
- return super.getJdbcConnection(readOnly);
- }
-
- /**
- * getPoolConnection.
- *
- * @return
- * @throws NoSuchMethodException
- * @throws IllegalArgumentException
- * @throws IllegalAccessException
- * @throws InvocationTargetException
- */
- protected Connection getPoolConnection() throws NoSuchMethodException,
IllegalArgumentException,
- IllegalAccessException, InvocationTargetException
- {
- Method getConnection = ociPool.getClass().getMethod("getConnection", new
Class[]{});
- return (Connection)getConnection.invoke(ociPool, new Object[]{});
- }
-
- protected void reconfigure() throws NoSuchMethodException, IllegalArgumentException,
IllegalAccessException,
- InvocationTargetException, NoSuchFieldException
- {
- if (ociPool != null)
- {
- // Set up the initial pool configuration
- Properties p1 = new Properties();
- String minLimitName =
(String)ociPool.getClass().getField("CONNPOOL_MIN_LIMIT").get(null);
- String maxLimitName =
(String)ociPool.getClass().getField("CONNPOOL_MAX_LIMIT").get(null);
- String incrName =
(String)ociPool.getClass().getField("CONNPOOL_INCREMENT").get(null);
-
- p1.put(minLimitName, Integer.toString(CONNPOOL_MIN_LIMIT));
- p1.put(maxLimitName, Integer.toString(CONNPOOL_MAX_LIMIT));
- p1.put(incrName, Integer.toString(CONNPOOL_INCREMENT));
-
- // Enable the initial configuration
- ociPool.getClass().getMethod("setPoolConfig", new
Class[]{Properties.class}).invoke(ociPool, new Object[]{p1});
- }
- }
-
- /**
- * Display the current status of the OracleOCIConnectionPool.
- */
- protected void displayPoolConfig() throws NoSuchMethodException,
IllegalArgumentException, IllegalAccessException,
- InvocationTargetException
- {
- if (ociPool != null)
- {
-
- log.info(" =========== Oracle OCI connection pool config ===========
");
-
- log.info(" Min poolsize Limit:\t"
- + ociPool.getClass().getMethod("getMinLimit", new
Class[]{}).invoke(ociPool, new Object[]{}));
-
- log.info(" Max poolsize Limit:\t"
- + ociPool.getClass().getMethod("getMaxLimit", new
Class[]{}).invoke(ociPool, new Object[]{}));
-
- log.info(" PoolSize:\t\t\t"
- + ociPool.getClass().getMethod("getPoolSize", new
Class[]{}).invoke(ociPool, new Object[]{}));
-
- log.info(" ActiveSize:\t\t"
- + ociPool.getClass().getMethod("getActiveSize", new
Class[]{}).invoke(ociPool, new Object[]{}));
- }
- }
-
-}
Deleted:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java.orig
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java.orig 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java.orig 2012-03-14
13:28:03 UTC (rev 5863)
@@ -1,711 +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.db;
-
-import org.exoplatform.services.jcr.datamodel.NodeData;
-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.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;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.List;
-
-/**
- * Single database connection implementation.
- *
- * Created by The eXo Platform SAS 27.04.2006
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
- * Nedonosko</a>
- * @version $Id: SingleDbJDBCConnection.java 20950 2008-10-06 14:23:07Z
- * pnedonosko $
- */
-public class SingleDbJDBCConnection extends JDBCStorageConnection
-{
-
- /**
- * 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
- */
- public SingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
- throws SQLException
- {
-
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getInternalId(final String identifier)
- {
- return containerName + identifier;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getIdentifier(final String internalId)
- {
-
- if (internalId == null) // possible for root parent
- return null;
-
- return internalId.substring(containerName.length());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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 =
- "select * from JCR_SITEM"
- + " where CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=?
order by I_CLASS, VERSION DESC";
-
- FIND_PROPERTY_BY_NAME =
- "select V.DATA"
- + " from JCR_SITEM I, JCR_SVALUE V"
- + " where I.I_CLASS=2 and I.CONTAINER_NAME=? 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_SREF R, JCR_SITEM P"
- + " where R.NODE_ID=? and P.CONTAINER_NAME=? 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_SVALUE where
PROPERTY_ID=? order by ORDER_NUM";
-
- FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from
JCR_SVALUE where PROPERTY_ID=?";
-
- FIND_VALUE_BY_PROPERTYID_OREDERNUMB =
- "select DATA, STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=? and
ORDER_NUM=?";
-
- FIND_NODES_BY_PARENTID =
- "select * from JCR_SITEM" + " where I_CLASS=1 and
CONTAINER_NAME=? and PARENT_ID=?" + " order by N_ORDER_NUM";
-
- FIND_LAST_ORDER_NUMBER_BY_PARENTID =
- "select count(*), max(N_ORDER_NUM) from JCR_SITEM where I_CLASS=1 and
CONTAINER_NAME=? and PARENT_ID=?";
-
- FIND_NODES_COUNT_BY_PARENTID =
- "select count(ID) from JCR_SITEM" + " where I_CLASS=1 and
CONTAINER_NAME=? and PARENT_ID=?";
-
- FIND_PROPERTIES_BY_PARENTID =
- "select * from JCR_SITEM" + " where I_CLASS=2 and
CONTAINER_NAME=? and PARENT_ID=?" + " order by ID";
-
- FIND_LOWEST_PROPERTY_VERSIONS =
- "select max(VERSION) as MAX_VERSION, PARENT_ID, NAME, CONTAINER_NAME,
I_CLASS, I_INDEX from JCR_SITEM WHERE I_CLASS=2"
- + " GROUP BY PARENT_ID, CONTAINER_NAME, NAME, I_CLASS, I_INDEX HAVING
count(VERSION) > 1";
-
- INSERT_NODE =
- "insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION,
I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,?,"
- + I_CLASS_NODE + ",?,?)";
- INSERT_PROPERTY =
- "insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION,
I_CLASS, I_INDEX, P_TYPE, P_MULTIVALUED) "
- + "VALUES(?,?,?,?,?," + I_CLASS_PROPERTY + ",?,?,?)";
-
- INSERT_VALUE = "insert into JCR_SVALUE(DATA, ORDER_NUM, PROPERTY_ID,
STORAGE_DESC) VALUES(?,?,?,?)";
- INSERT_REF = "insert into JCR_SREF(NODE_ID, PROPERTY_ID, ORDER_NUM)
VALUES(?,?,?)";
-
- RENAME_NODE = "update JCR_SITEM set PARENT_ID=?, NAME=?, VERSION=?, I_INDEX=?,
N_ORDER_NUM=? where ID=?";
-
- UPDATE_NODE = "update JCR_SITEM set VERSION=?, I_INDEX=?, N_ORDER_NUM=? where
ID=?";
- UPDATE_PROPERTY = "update JCR_SITEM set VERSION=?, P_TYPE=? where ID=?";
- //UPDATE_VALUE = "update JCR_SVALUE set DATA=?, STORAGE_DESC=? where
PROPERTY_ID=?, ORDER_NUM=?";
-
- DELETE_ITEM = "delete from JCR_SITEM where ID=?";
- DELETE_VALUE = "delete from JCR_SVALUE where PROPERTY_ID=?";
- DELETE_REF = "delete from JCR_SREF where PROPERTY_ID=?";
-
- FIND_NODES_COUNT = "select count(*) from JCR_SITEM I where I.I_CLASS=1 and
I.CONTAINER_NAME=?";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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.setInt(5, data.getPersistedVersion());
- insertNode.setInt(6, data.getQPath().getIndex());
- insertNode.setInt(7, data.getOrderNumber());
- return insertNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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.setInt(5, data.getPersistedVersion());
- insertProperty.setInt(6, data.getQPath().getIndex());
- insertProperty.setInt(7, data.getType());
- insertProperty.setBoolean(8, data.isMultiValued());
-
- return insertProperty.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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;
- for (int i = 0; i < values.size(); i++)
- {
- ValueData vdata = values.get(i);
- String refNodeIdentifier = new String(vdata.getAsByteArray());
-
- insertReference.setString(1, getInternalId(refNodeIdentifier));
- insertReference.setString(2, getInternalId(data.getIdentifier()));
- insertReference.setInt(3, i);
- added += insertReference.executeUpdate();
- }
- return added;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(2, parentCid);
- return findNodesByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(2, parentIdentifier);
- return findLastOrderNumberByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(2, parentCid);
- return findNodesCountByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(2, parentCid);
- return findPropertiesByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(2, parentId);
- findItemByName.setString(3, name);
- findItemByName.setInt(4, index);
- return findItemByName.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(2, parentCid);
- findPropertyByName.setString(3, name);
- return findPropertyByName.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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);
- return findReferences.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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);
- updateNode.setInt(3, orderNumb);
- updateNode.setString(4, cid);
- return updateNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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);
- updateProperty.setString(3, cid);
- return updateProperty.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- protected ResultSet findChildNodesByParentIdentifier(String parentCid, int
fromOrderNum, int toOrderNum)
- throws SQLException
- {
- throw new UnsupportedOperationException("findChildNodesByParentIdentifier is
not supported for old queries");
- }
-
- // -------- values processing ------------
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addValueData(String cid, int orderNumber, InputStream stream, int
streamLength, String storageDesc)
- throws SQLException
- {
-
- if (insertValue == null)
- insertValue = dbConnection.prepareStatement(INSERT_VALUE);
- else
- insertValue.clearParameters();
-
- if (stream == null)
- {
- // [PN] store vd reference to external storage etc.
- insertValue.setNull(1, Types.BINARY);
- insertValue.setString(4, storageDesc);
- }
- else
- {
- insertValue.setBinaryStream(1, stream, streamLength);
- insertValue.setNull(4, Types.VARCHAR);
- }
-
- insertValue.setInt(2, orderNumber);
- insertValue.setString(3, cid);
- return insertValue.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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);
- return findValueByPropertyIdOrderNumber.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(2, data.getQPath().getName().getAsString());
- renameNode.setInt(3, data.getPersistedVersion());
- renameNode.setInt(4, data.getQPath().getIndex());
- renameNode.setInt(5, data.getOrderNumber());
- renameNode.setString(6, getInternalId(data.getIdentifier()));
- return renameNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findNodesAndProperties(String lastNodeId, int offset, int limit)
throws SQLException
- {
- throw new UnsupportedOperationException(
- "The method findNodesAndProperties is not supported for this type of
connection use the complex queries instead");
- }
-
- /**
- * {@inheritDoc}
- */
- protected void deleteLockProperties() throws SQLException
- {
- PreparedStatement removeValuesStatement = null;
- PreparedStatement removeItemsStatement = null;
-
- try
- {
- removeValuesStatement =
- 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);
-
- 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);
-
- removeValuesStatement.executeUpdate();
- removeItemsStatement.executeUpdate();
- }
- finally
- {
- if (removeValuesStatement != null)
- {
- try
- {
- removeValuesStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
-
- if (removeItemsStatement != null)
- {
- try
- {
- removeItemsStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findNodesCount() throws SQLException
- {
- if (findNodesCount == null)
- {
- findNodesCount = dbConnection.prepareStatement(FIND_NODES_COUNT);
- }
- else
- {
- findNodesCount.clearParameters();
- }
-
- findNodesCount.setString(1, containerName);
-
- return findNodesCount.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- protected void deleteLockProperties(String nodeIdentifier) throws SQLException
- {
- PreparedStatement removeValuesStatement = null;
- PreparedStatement removeItemsStatement = null;
-
- try
- {
- removeValuesStatement =
- 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(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(2, getInternalId(nodeIdentifier));
-
- removeValuesStatement.executeUpdate();
- removeItemsStatement.executeUpdate();
- }
- finally
- {
- if (removeValuesStatement != null)
- {
- try
- {
- removeValuesStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
-
- if (removeItemsStatement != null)
- {
- try
- {
- removeItemsStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
- }
- }
-}
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-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/IngresSQLDBInitializer.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.init;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
+import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
import java.io.IOException;
import java.sql.Connection;
@@ -37,7 +38,7 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
* @version $Id: IngresSQLDBInitializer.java 34801 2009-07-31 15:44:50Z dkatayev $
*/
-public class IngresSQLDBInitializer extends StorageDBInitializer
+public class IngresSQLDBInitializer extends DBInitializer
{
public IngresSQLDBInitializer(Connection connection, JDBCDataContainerConfig
containerConfig) throws IOException
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-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/OracleDBInitializer.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.init;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
+import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
import java.io.IOException;
import java.sql.Connection;
@@ -37,7 +38,7 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
* @version $Id: OracleDBInitializer.java 34801 2009-07-31 15:44:50Z dkatayev $
*/
-public class OracleDBInitializer extends StorageDBInitializer
+public class OracleDBInitializer extends DBInitializer
{
public OracleDBInitializer(Connection connection, JDBCDataContainerConfig
containerConfig) throws IOException
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-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/PgSQLDBInitializer.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.init;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
+import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
import java.io.IOException;
import java.sql.Connection;
@@ -35,7 +36,7 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
* @version $Id: PgSQLDBInitializer.java 34801 2009-07-31 15:44:50Z dkatayev $
*/
-public class PgSQLDBInitializer extends StorageDBInitializer
+public class PgSQLDBInitializer extends DBInitializer
{
public PgSQLDBInitializer(Connection connection, JDBCDataContainerConfig
containerConfig) throws IOException
Deleted:
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-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/StorageDBInitializer.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -1,95 +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.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;
-
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-/**
- * JCR Storage DB initializer.
- *
- * Created by The eXo Platform SAS 12.03.2007.
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
- * @version $Id$
- */
-public class StorageDBInitializer extends DBInitializer
-{
- public StorageDBInitializer(Connection connection, JDBCDataContainerConfig
containerConfig) throws IOException
- {
- super(connection, containerConfig);
- }
-
- protected String prepareScripts() throws IOException
- {
- if (containerConfig.dbStructureType == DatabaseStructureType.ISOLATED)
- {
- // Replace the names of Database entities
- String scripts = super.prepareScripts();
-
- return scripts.replace("MITEM", "I" +
containerConfig.dbTableSuffix)
- .replace("MVALUE", "V" + containerConfig.dbTableSuffix)
- .replace("MREF", "R" + containerConfig.dbTableSuffix);
- }
- else
- {
- return super.prepareScripts();
- }
-
- }
-
- /**
- * Init root node parent record.
- */
- @Override
- protected void postInit(Connection connection) throws SQLException
- {
- 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_" + tableSuffix + " where ID='" +
Constants.ROOT_PARENT_UUID + "' and PARENT_ID='"
- + Constants.ROOT_PARENT_UUID + "'";
-
- if (!connection.createStatement().executeQuery(select).next())
- {
- // 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/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-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -27,19 +27,17 @@
import org.exoplatform.services.jcr.impl.storage.jdbc.init.IngresSQLDBInitializer;
import org.exoplatform.services.jcr.impl.storage.jdbc.init.OracleDBInitializer;
import org.exoplatform.services.jcr.impl.storage.jdbc.init.PgSQLDBInitializer;
-import org.exoplatform.services.jcr.impl.storage.jdbc.init.StorageDBInitializer;
import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.DB2ConnectionFactory;
import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.DefaultOracleConnectionFactory;
import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.GenericCQConnectionFactory;
import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.HSQLDBConnectionFactory;
import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.MSSQLConnectionFactory;
import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.MySQLConnectionFactory;
-import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.OracleConnectionFactory;
import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.PostgreConnectionFactory;
import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.SybaseConnectionFactory;
import org.exoplatform.services.jcr.impl.util.io.FileCleanerHolder;
+import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerException;
-import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
import org.exoplatform.services.jdbc.DataSourceProvider;
import org.exoplatform.services.naming.InitialContextInitializer;
@@ -94,20 +92,11 @@
@Override
protected void initDatabase() throws NamingException, RepositoryException,
IOException
{
-
- StorageDBInitializer dbInitializer = null;
+ DBInitializer dbInitializer = null;
if (containerConfig.dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
{
LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is
experimental!");
- // sample of connection factory customization
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new DefaultOracleConnectionFactory(getDataSource(),
containerConfig);
- }
- else
- {
- this.connFactory = new OracleConnectionFactory(containerConfig);
- }
+ this.connFactory = new DefaultOracleConnectionFactory(getDataSource(),
containerConfig);
// a particular db initializer may be configured here too
dbInitializer =
@@ -115,28 +104,11 @@
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_ORACLE)
{
-
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new DefaultOracleConnectionFactory(getDataSource(),
containerConfig);
- }
- else
- {
- this.connFactory = new DefaultOracleConnectionFactory(containerConfig);
- }
-
+ this.connFactory = new DefaultOracleConnectionFactory(getDataSource(),
containerConfig);
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_PGSQL)
{
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new PostgreConnectionFactory(getDataSource(),
containerConfig);
- }
- else
- {
- this.connFactory = new PostgreConnectionFactory(containerConfig);
- }
-
+ this.connFactory = new PostgreConnectionFactory(getDataSource(),
containerConfig);
dbInitializer =
new PgSQLDBInitializer(this.connFactory.getJdbcConnection(),
containerConfig);
}
@@ -152,28 +124,13 @@
+ " 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 (containerConfig.dbSourceName != null)
- {
- this.connFactory = new MySQLConnectionFactory(getDataSource(),
containerConfig);
- }
- else
- {
- this.connFactory = new MySQLConnectionFactory(containerConfig);
- }
+ this.connFactory = new MySQLConnectionFactory(getDataSource(),
containerConfig);
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_MSSQL)
{
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new MSSQLConnectionFactory(getDataSource(),
containerConfig);
- }
- else
- {
- this.connFactory = new MSSQLConnectionFactory(containerConfig);
- }
-
+ this.connFactory = new MSSQLConnectionFactory(getDataSource(),
containerConfig);
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_DERBY)
@@ -183,41 +140,17 @@
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_DB2)
{
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new DB2ConnectionFactory(getDataSource(),
containerConfig);
- }
- else
- {
- this.connFactory = new DB2ConnectionFactory(containerConfig);
- }
-
+ new DB2ConnectionFactory(getDataSource(), containerConfig);
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_DB2V8)
{
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new DB2ConnectionFactory(getDataSource(),
containerConfig);
- }
- else
- {
- this.connFactory = new DB2ConnectionFactory(containerConfig);
- }
-
+ new DB2ConnectionFactory(getDataSource(), containerConfig);
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_SYBASE)
{
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new SybaseConnectionFactory(getDataSource(),
containerConfig);
- }
- else
- {
- this.connFactory = new SybaseConnectionFactory(containerConfig);
- }
-
+ this.connFactory = new SybaseConnectionFactory(getDataSource(),
containerConfig);
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_INGRES)
@@ -229,14 +162,7 @@
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_HSQLDB)
{
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new HSQLDBConnectionFactory(getDataSource(),
containerConfig);
- }
- else
- {
- this.connFactory = new HSQLDBConnectionFactory(containerConfig);
- }
+ this.connFactory = new HSQLDBConnectionFactory(getDataSource(),
containerConfig);
dbInitializer = defaultDBInitializer();
}
else
@@ -269,12 +195,6 @@
@Override
protected GenericConnectionFactory defaultConnectionFactory() throws NamingException,
RepositoryException
{
- // by default
- if (containerConfig.dbSourceName != null)
- {
- return new GenericCQConnectionFactory(getDataSource(), containerConfig);
- }
-
- return new GenericCQConnectionFactory(containerConfig);
+ return new GenericCQConnectionFactory(getDataSource(), 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-14
09:31:09 UTC (rev 5862)
+++
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-14
13:28:03 UTC (rev 5863)
@@ -19,13 +19,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.util.io.FileCleaner;
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.DatabaseMetaData;
import java.sql.SQLException;
@@ -49,14 +46,6 @@
private Boolean isReindexingSupport;
/**
- * DB2ConnectionFactory constructor.
- */
- public DB2ConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
- {
- super(containerConfig);
- }
-
- /**
* DB2ConnectionFactory constructor.
*/
public DB2ConnectionFactory(DataSource dataSource, JDBCDataContainerConfig
containerConfig)
@@ -72,7 +61,7 @@
{
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new DB2MultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
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-14
09:31:09 UTC (rev 5862)
+++
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-14
13:28:03 UTC (rev 5863)
@@ -41,15 +41,6 @@
}
/**
- * DefaultOracleConnectionFactory constructor.
- */
- public DefaultOracleConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
- {
-
- super(containerConfig);
- }
-
- /**
* {@inheritDoc}
*/
@Override
@@ -59,7 +50,7 @@
{
if (containerConfig.useQueryHints)
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new OracleMultiDbJDBCConnection(getJdbcConnection(readOnly),
readOnly,
containerConfig);
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-14
09:31:09 UTC (rev 5862)
+++
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-14
13:28:03 UTC (rev 5863)
@@ -18,13 +18,11 @@
*/
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.storage.WorkspaceStorageConnection;
import java.sql.Connection;
-import java.sql.DriverManager;
import java.sql.SQLException;
import javax.jcr.RepositoryException;
@@ -50,32 +48,6 @@
}
/**
- * GenericConnectionFactory constructor.
- */
- public GenericCQConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
- {
-
- this(null, containerConfig);
-
- try
- {
- ClassLoading.forName(this.containerConfig.dbDriver, this).newInstance();
- }
- catch (InstantiationException e)
- {
- throw new RepositoryException(e);
- }
- catch (IllegalAccessException e)
- {
- throw new RepositoryException(e);
- }
- catch (ClassNotFoundException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
* {@inheritDoc}
*/
@Override
@@ -93,7 +65,7 @@
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new MultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
@@ -115,12 +87,7 @@
{
try
{
- 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;
+ return dbDataSource.getConnection();
}
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/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-14
09:31:09 UTC (rev 5862)
+++
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-14
13:28:03 UTC (rev 5863)
@@ -45,15 +45,6 @@
}
/**
- * HSQLDBConnectionFactory constructor.
- */
- public HSQLDBConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
- {
-
- super(containerConfig);
- }
-
- /**
* {@inheritDoc}
*/
public WorkspaceStorageConnection openConnection(boolean readOnly) throws
RepositoryException
@@ -61,7 +52,7 @@
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new HSQLDBMultiDbJDBCConnection(getJdbcConnection(readOnly),
readOnly,
containerConfig);
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-14
09:31:09 UTC (rev 5862)
+++
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-14
13:28:03 UTC (rev 5863)
@@ -38,14 +38,6 @@
{
/**
- * MSSQLConnectionFactory constructor.
- */
- public MSSQLConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
- {
- super(containerConfig);
- }
-
- /**
* MSSQLConnectionFactory constructor.
*/
public MSSQLConnectionFactory(DataSource dbDataSource, JDBCDataContainerConfig
containerConfig)
@@ -61,7 +53,7 @@
{
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new MSSQLMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
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-14
09:31:09 UTC (rev 5862)
+++
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-14
13:28:03 UTC (rev 5863)
@@ -38,15 +38,6 @@
{
/**
- * MySQLConnectionFactory constructor.
- */
- public MySQLConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
- {
-
- super(containerConfig);
- }
-
- /**
* MySQLConnectionFactory constructor.
*/
public MySQLConnectionFactory(DataSource dbDataSource, JDBCDataContainerConfig
containerConfig)
@@ -64,7 +55,7 @@
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new MySQLMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
Deleted:
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-14
09:31:09 UTC (rev 5862)
+++
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-14
13:28:03 UTC (rev 5863)
@@ -1,195 +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.optimisation.db;
-
-import org.exoplatform.commons.utils.ClassLoading;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.sql.Connection;
-import java.util.Properties;
-
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS
- *
- * 23.03.2007
- *
- * Access Oracle implicit connection caching and pooling stuff using reflection to
prevent Maven
- * dependecies on ora drivers from POM.
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
- * @version $Id$
- */
-public class OracleConnectionFactory extends DefaultOracleConnectionFactory
-{
-
- public static int CONNCACHE_MAX_LIMIT = 25;
-
- public static int CONNCACHE_MIN_LIMIT = 2;
-
- public static int CONNCACHE_INACTIVITY_TIMEOUT = 3600;
-
- public static int CONNCACHE_ABADONDED_TIMEOUT = 1800;
-
- protected final Object ociDataSource;
-
- /**
- * OracleConnectionFactory constructor. For CLI interface ONLY!
- */
- public OracleConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
- {
-
- // ;D:\Devel\oracle_instantclient_10_2\;C:\oracle\ora92\bin;
-
- /*
- * ERROR: if no oci in path and oci url requested Error:
- * java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
- *
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
- * at
- *
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl
- * .java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at
- * ocipool.ConnPoolAppl.main(ConnPoolAppl.java:58) Caused by:
java.lang.UnsatisfiedLinkError: no
- * ocijdbc10 in java.library.path at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
- * ---------------------------------------------------------------------------
ERROR: if thin
- * url used and trying obtain oci data source
java.lang.reflect.InvocationTargetException at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
- *
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
- * at
- *
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl
- * .java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at
- * ocipool.ConnPoolAppl.main(ConnPoolAppl.java:58) Caused by:
java.lang.ClassCastException:
- * oracle.jdbc.driver.T4CConnection at
- * oracle.jdbc.pool.OracleOCIConnectionPool.createConnectionPool
- * (OracleOCIConnectionPool.java:893)
- */
-
- super(containerConfig);
-
- Object cds = null;
- try
- {
- Class<?> cdsClass =
ClassLoading.loadClass("oracle.jdbc.pool.OracleDataSource", this);
- Constructor<?> cdsConstructor = cdsClass.getConstructor(new Class[]{});
- cds = cdsConstructor.newInstance(new Object[]{});
-
- // set cache properties
- Properties prop = new java.util.Properties();
- prop.setProperty("InitialLimit",
String.valueOf(CONNCACHE_MIN_LIMIT));
- prop.setProperty("MinLimit", String.valueOf(CONNCACHE_MIN_LIMIT));
- prop.setProperty("MaxLimit", String.valueOf(CONNCACHE_MAX_LIMIT));
- prop.setProperty("InactivityTimeout",
String.valueOf(CONNCACHE_INACTIVITY_TIMEOUT));
- prop.setProperty("AbandonedConnectionTimeout",
String.valueOf(CONNCACHE_ABADONDED_TIMEOUT));
-
- Method setURL = cds.getClass().getMethod("setURL", new
Class[]{String.class});
- setURL.invoke(cds, new Object[]{this.containerConfig.dbUrl});
-
- Method setUser = cds.getClass().getMethod("setUser", new
Class[]{String.class});
- setUser.invoke(cds, new Object[]{this.containerConfig.dbUserName});
-
- Method setPassword = cds.getClass().getMethod("setPassword", new
Class[]{String.class});
- setPassword.invoke(cds, new Object[]{this.containerConfig.dbPassword});
-
- Method setConnectionCachingEnabled =
- cds.getClass().getMethod("setConnectionCachingEnabled", new
Class[]{boolean.class});
- setConnectionCachingEnabled.invoke(cds, new Object[]{true});
-
- Method setConnectionCacheProperties =
- cds.getClass().getMethod("setConnectionCacheProperties", new
Class[]{Properties.class});
- setConnectionCacheProperties.invoke(cds, new Object[]{prop});
-
- Method setConnectionCacheName =
cds.getClass().getMethod("setConnectionCacheName", new Class[]{String.class});
- 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);
- 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
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Connection getJdbcConnection(boolean readOnly) throws RepositoryException
- {
- if (ociDataSource != null)
- {
- try
- {
- Connection conn = getCachedConnection();
-
- if (readOnly)
- {
- // set this feature only if it asked
- conn.setReadOnly(true);
- }
-
- return conn;
- }
- catch (Throwable e)
- {
- throw new RepositoryException("Oracle OCI cached connection open error
" + e, e);
- }
- }
-
- return super.getJdbcConnection(readOnly);
- }
-
- /**
- * Get CachedConnection.
- *
- * @return
- * @throws NoSuchMethodException
- * @throws IllegalArgumentException
- * @throws IllegalAccessException
- * @throws InvocationTargetException
- */
- protected Connection getCachedConnection() throws NoSuchMethodException,
IllegalArgumentException,
- IllegalAccessException, InvocationTargetException
- {
-
- // NOTE: ociDataSource - actually instance of javax.sql.DataSource
- Method getConnection =
ociDataSource.getClass().getMethod("getConnection", new Class[]{});
- Connection conn = (Connection)getConnection.invoke(ociDataSource, new Object[]{});
-
- return conn;
- }
-
-}
Deleted:
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-14
09:31:09 UTC (rev 5862)
+++
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-14
13:28:03 UTC (rev 5863)
@@ -1,227 +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.optimisation.db;
-
-import org.exoplatform.commons.utils.ClassLoading;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.sql.Connection;
-import java.util.Properties;
-
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS
- *
- * 16.03.2007
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
- * @version $Id$
- */
-public class OraclePoolConnectionFactory extends GenericCQConnectionFactory
-{
-
- public static int CONNPOOL_MAX_LIMIT = 20;
-
- public static int CONNPOOL_MIN_LIMIT = 2;
-
- public static int CONNPOOL_INCREMENT = 1;
-
- protected final Object ociPool;
-
- /**
- * OraclePoolConnectionFactory constructor. For CLI interface ONLY!
- */
- public OraclePoolConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
- {
-
- // ;D:\Devel\oracle_instantclient_10_2\;C:\oracle\ora92\bin;
-
- /*
- * ERROR: if no oci in path and oci url requested Error:
- * java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
- *
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
- * at
- *
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl
- * .java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at
- * ocipool.ConnPoolAppl.main(ConnPoolAppl.java:58) Caused by:
java.lang.UnsatisfiedLinkError: no
- * ocijdbc10 in java.library.path at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
- * ---------------------------------------------------------------------------
ERROR: if thin
- * url used and trying obtain oci data source
java.lang.reflect.InvocationTargetException at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
- *
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
- * at
- *
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl
- * .java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at
- * ocipool.ConnPoolAppl.main(ConnPoolAppl.java:58) Caused by:
java.lang.ClassCastException:
- * oracle.jdbc.driver.T4CConnection at
- * oracle.jdbc.pool.OracleOCIConnectionPool.createConnectionPool
- * (OracleOCIConnectionPool.java:893)
- */
-
- super(containerConfig);
-
- Object cpool = null;
- try
- {
- Class<?> cpoolClass =
ClassLoading.loadClass("oracle.jdbc.pool.OracleOCIConnectionPool", this);
- Constructor<?> cpoolConstructor =
- cpoolClass.getConstructor(new Class[]{String.class, String.class,
String.class, Properties.class});
-
- 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});
- }
- catch (Throwable e)
- {
- cpool = null;
- 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;
-
- // configure using CONNPOOL_MAX_LIMIT, CONNPOOL_MIN_LIMIT, CONNPOOL_INCREMENT
- try
- {
- reconfigure();
- displayPoolConfig();
- }
- 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);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Connection getJdbcConnection(boolean readOnly) throws RepositoryException
- {
- if (ociPool != null)
- {
- try
- {
- Connection conn = getPoolConnection();
-
- if (readOnly)
- {
- // set this feature only if it asked
- conn.setReadOnly(true);
- }
-
- return conn;
- }
- catch (Throwable e)
- {
- throw new RepositoryException("Oracle OCI pool connection open error
" + e, e);
- }
- }
-
- return super.getJdbcConnection(readOnly);
- }
-
- /**
- * getPoolConnection.
- *
- * @return
- * @throws NoSuchMethodException
- * @throws IllegalArgumentException
- * @throws IllegalAccessException
- * @throws InvocationTargetException
- */
- protected Connection getPoolConnection() throws NoSuchMethodException,
IllegalArgumentException,
- IllegalAccessException, InvocationTargetException
- {
- Method getConnection = ociPool.getClass().getMethod("getConnection", new
Class[]{});
- return (Connection)getConnection.invoke(ociPool, new Object[]{});
- }
-
- protected void reconfigure() throws NoSuchMethodException, IllegalArgumentException,
IllegalAccessException,
- InvocationTargetException, NoSuchFieldException
- {
- if (ociPool != null)
- {
- // Set up the initial pool configuration
- Properties p1 = new Properties();
- String minLimitName =
(String)ociPool.getClass().getField("CONNPOOL_MIN_LIMIT").get(null);
- String maxLimitName =
(String)ociPool.getClass().getField("CONNPOOL_MAX_LIMIT").get(null);
- String incrName =
(String)ociPool.getClass().getField("CONNPOOL_INCREMENT").get(null);
-
- p1.put(minLimitName, Integer.toString(CONNPOOL_MIN_LIMIT));
- p1.put(maxLimitName, Integer.toString(CONNPOOL_MAX_LIMIT));
- p1.put(incrName, Integer.toString(CONNPOOL_INCREMENT));
-
- // Enable the initial configuration
- ociPool.getClass().getMethod("setPoolConfig", new
Class[]{Properties.class}).invoke(ociPool, new Object[]{p1});
- }
- }
-
- /**
- * Display the current status of the OracleOCIConnectionPool.
- */
- protected void displayPoolConfig() throws NoSuchMethodException,
IllegalArgumentException, IllegalAccessException,
- InvocationTargetException
- {
- if (ociPool != null)
- {
-
- log.info(" =========== Oracle OCI connection pool config ===========
");
-
- log.info(" Min poolsize Limit:\t"
- + ociPool.getClass().getMethod("getMinLimit", new
Class[]{}).invoke(ociPool, new Object[]{}));
-
- log.info(" Max poolsize Limit:\t"
- + ociPool.getClass().getMethod("getMaxLimit", new
Class[]{}).invoke(ociPool, new Object[]{}));
-
- log.info(" PoolSize:\t\t\t"
- + ociPool.getClass().getMethod("getPoolSize", new
Class[]{}).invoke(ociPool, new Object[]{}));
-
- log.info(" ActiveSize:\t\t"
- + ociPool.getClass().getMethod("getActiveSize", new
Class[]{}).invoke(ociPool, new Object[]{}));
- }
- }
-
-}
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-14
09:31:09 UTC (rev 5862)
+++
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-14
13:28:03 UTC (rev 5863)
@@ -34,13 +34,6 @@
*/
public class PostgreConnectionFactory extends GenericCQConnectionFactory
{
- /**
- * PostgreConnectionFactory constructor.
- */
- public PostgreConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
- {
- super(containerConfig);
- }
/**
* PostgreConnectionFactory constructor.
@@ -58,7 +51,7 @@
{
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new PostgreMultiDbJDBCConnection(getJdbcConnection(readOnly),
readOnly, containerConfig);
}
Deleted:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java.orig
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java.orig 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java.orig 2012-03-14
13:28:03 UTC (rev 5863)
@@ -1,1090 +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.optimisation.db;
-
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.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.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;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.List;
-
-/**
- * Single database connection implementation.
- *
- * Created by The eXo Platform SAS 27.04.2006
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
- * Nedonosko</a>
- * @version $Id: SingleDbJDBCConnection.java 20950 2008-10-06 14:23:07Z
- * pnedonosko $
- */
-public class SingleDbJDBCConnection extends CQJDBCStorageConnection
-{
-
- protected static final String FIND_NODES_BY_PARENTID_CQ_QUERY =
- "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA from JCR_SITEM I,
JCR_SITEM P, JCR_SVALUE V"
- + " where I.I_CLASS=1 and I.CONTAINER_NAME=? and I.PARENT_ID=? and"
- + " P.I_CLASS=2 and P.CONTAINER_NAME=? 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 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_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 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
- */
- public SingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
- throws SQLException
- {
-
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getInternalId(final String identifier)
- {
- return containerName + identifier;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getIdentifier(final String internalId)
- {
-
- if (internalId == null) // possible for root parent
- return null;
-
- return internalId.substring(containerName.length());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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 =
- "select * from JCR_SITEM"
- + " where CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=?
order by I_CLASS, VERSION DESC";
-
- FIND_PROPERTY_BY_NAME =
- "select V.DATA from JCR_SITEM I, JCR_SVALUE V"
- + " where I.I_CLASS=2 and I.CONTAINER_NAME=? 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_SREF R, JCR_SITEM P"
- + " where R.NODE_ID=? and P.CONTAINER_NAME=? 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_SVALUE where
PROPERTY_ID=? order by ORDER_NUM";
-
- FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from
JCR_SVALUE where PROPERTY_ID=?";
-
- FIND_VALUE_BY_PROPERTYID_OREDERNUMB =
- "select DATA, STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=? and
ORDER_NUM=?";
-
- FIND_NODES_BY_PARENTID =
- "select * from JCR_SITEM" + " where I_CLASS=1 and
CONTAINER_NAME=? 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_SITEM I, JCR_SVALUE V"
- + " where I.I_CLASS=2 and I.CONTAINER_NAME=? 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"
- + "
I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and
I.ID=V.PROPERTY_ID";
-
- 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_SITEM where I_CLASS=1 and
CONTAINER_NAME=? and PARENT_ID=?";
-
- FIND_NODES_COUNT_BY_PARENTID =
- "select count(ID) from JCR_SITEM" + " where I_CLASS=1 and
CONTAINER_NAME=? and PARENT_ID=?";
-
- FIND_PROPERTIES_BY_PARENTID =
- "select * from JCR_SITEM" + " where I_CLASS=2 and
CONTAINER_NAME=? and PARENT_ID=?" + " order by NAME";
-
- 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_SITEM I LEFT OUTER JOIN JCR_SVALUE 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_SITEM I,
JCR_SITEM P, JCR_SVALUE V";
-
- FIND_LOWEST_PROPERTY_VERSIONS =
- "select max(VERSION) as MAX_VERSION, PARENT_ID, NAME, CONTAINER_NAME,
I_CLASS, I_INDEX from JCR_SITEM WHERE I_CLASS=2"
- + " GROUP BY PARENT_ID, CONTAINER_NAME, NAME, I_CLASS, I_INDEX HAVING
count(VERSION) > 1";
-
- INSERT_NODE =
- "insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION,
I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,?,"
- + I_CLASS_NODE + ",?,?)";
- INSERT_PROPERTY =
- "insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION,
I_CLASS, I_INDEX, P_TYPE, P_MULTIVALUED)"
- + " VALUES(?,?,?,?,?," + I_CLASS_PROPERTY + ",?,?,?)";
-
- INSERT_VALUE = "insert into JCR_SVALUE(DATA, ORDER_NUM, PROPERTY_ID,
STORAGE_DESC) VALUES(?,?,?,?)";
- INSERT_REF = "insert into JCR_SREF(NODE_ID, PROPERTY_ID, ORDER_NUM)
VALUES(?,?,?)";
-
- RENAME_NODE = "update JCR_SITEM set PARENT_ID=?, NAME=?, VERSION=?, I_INDEX=?,
N_ORDER_NUM=? where ID=?";
-
- UPDATE_NODE = "update JCR_SITEM set VERSION=?, I_INDEX=?, N_ORDER_NUM=? where
ID=?";
- UPDATE_PROPERTY = "update JCR_SITEM set VERSION=?, P_TYPE=? where ID=?";
-
- DELETE_ITEM = "delete from JCR_SITEM where ID=?";
- DELETE_VALUE = "delete from JCR_SVALUE where PROPERTY_ID=?";
- DELETE_REF = "delete from JCR_SREF 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_SVALUE V, JCR_SITEM
P"
- + " join (select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_INDEX,
I.N_ORDER_NUM from JCR_SITEM I"
- + " where I.CONTAINER_NAME=? AND 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 P.CONTAINER_NAME=? and V.PROPERTY_ID=P.ID
order by J.ID";
-
- FIND_PROPERTY_BY_ID =
- "select I.P_TYPE, V.STORAGE_DESC from JCR_SITEM I, JCR_SVALUE V where I.ID
= ? and V.PROPERTY_ID = I.ID";
- DELETE_VALUE_BY_ORDER_NUM = "delete from JCR_SVALUE where PROPERTY_ID=? and
ORDER_NUM >= ?";
- UPDATE_VALUE = "update JCR_SVALUE 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_SITEM I,
JCR_SITEM P, JCR_SVALUE V"
- + " where I.I_CLASS=1 and I.CONTAINER_NAME=? and I.PARENT_ID=? and
I.N_ORDER_NUM >= ? and "
- + " I.N_ORDER_NUM <= ? and P.I_CLASS=2 and P.CONTAINER_NAME=? 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_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')";
-
- FIND_NODES_COUNT = "select count(*) from JCR_SITEM I where I.I_CLASS=1 and
I.CONTAINER_NAME=?";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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.setInt(5, data.getPersistedVersion());
- insertNode.setInt(6, data.getQPath().getIndex());
- insertNode.setInt(7, data.getOrderNumber());
- return insertNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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.setInt(5, data.getPersistedVersion());
- insertProperty.setInt(6, data.getQPath().getIndex());
- insertProperty.setInt(7, data.getType());
- insertProperty.setBoolean(8, data.isMultiValued());
-
- return insertProperty.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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;
- for (int i = 0; i < values.size(); i++)
- {
- ValueData vdata = values.get(i);
- String refNodeIdentifier = new String(vdata.getAsByteArray());
-
- insertReference.setString(1, getInternalId(refNodeIdentifier));
- insertReference.setString(2, getInternalId(data.getIdentifier()));
- insertReference.setInt(3, i);
- added += insertReference.executeUpdate();
- }
- return added;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(2, parentCid);
- return findNodesByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(2, parentIdentifier);
- return findLastOrderNumberByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(2, parentCid);
- return findNodesCountByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(2, parentCid);
- return findPropertiesByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(2, parentId);
- findItemByName.setString(3, name);
- findItemByName.setInt(4, index);
- return findItemByName.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(2, parentCid);
- findPropertyByName.setString(3, name);
- return findPropertyByName.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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);
- return findReferences.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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);
- updateNode.setInt(3, orderNumb);
- updateNode.setString(4, cid);
- return updateNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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);
- updateProperty.setString(3, cid);
- return updateProperty.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- protected ResultSet findChildNodesByParentIdentifier(String parentCid, int
fromOrderNum, int toOrderNum)
- throws SQLException
- {
- if (findNodesByParentIdLazilyCQ == null)
- findNodesByParentIdLazilyCQ =
dbConnection.prepareStatement(FIND_NODES_BY_PARENTID_LAZILY_CQ);
- else
- findNodesByParentIdLazilyCQ.clearParameters();
-
- findNodesByParentIdLazilyCQ.setString(1, containerName);
- findNodesByParentIdLazilyCQ.setString(2, parentCid);
- findNodesByParentIdLazilyCQ.setInt(3, fromOrderNum);
- findNodesByParentIdLazilyCQ.setInt(4, toOrderNum);
- findNodesByParentIdLazilyCQ.setString(5, containerName);
-
- return findNodesByParentIdLazilyCQ.executeQuery();
- }
-
- // -------- values processing ------------
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addValueData(String cid, int orderNumber, InputStream stream, int
streamLength, String storageDesc)
- throws SQLException
- {
- if (insertValue == null)
- insertValue = dbConnection.prepareStatement(INSERT_VALUE);
- else
- insertValue.clearParameters();
-
- if (stream == null)
- {
- // [PN] store vd reference to external storage etc.
- insertValue.setNull(1, Types.BINARY);
- insertValue.setString(4, storageDesc);
- }
- else
- {
- insertValue.setBinaryStream(1, stream, streamLength);
- insertValue.setNull(4, Types.VARCHAR);
- }
-
- insertValue.setInt(2, orderNumber);
- insertValue.setString(3, cid);
- return insertValue.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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);
- return findValueByPropertyIdOrderNumber.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(2, data.getQPath().getName().getAsString());
- renameNode.setInt(3, data.getPersistedVersion());
- renameNode.setInt(4, data.getQPath().getIndex());
- renameNode.setInt(5, data.getOrderNumber());
- renameNode.setString(6, getInternalId(data.getIdentifier()));
- return renameNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(2, parentIdentifier);
- findNodesByParentIdCQ.setString(3, containerName);
- return findNodesByParentIdCQ.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier,
List<QPathEntryFilter> pattern)
- throws SQLException
- {
- if (pattern.isEmpty())
- {
- throw new SQLException("Pattern list is empty.");
- }
- else
- {
- if (findNodesByParentIdAndComplexPatternCQ == null)
- {
- findNodesByParentIdAndComplexPatternCQ = dbConnection.createStatement();
- }
- //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("' and I.PARENT_ID='");
- query.append(parentIdentifier);
- query.append("' and ( ");
- appendPattern(query, pattern.get(0).getQPathEntry(), true);
- for (int i = 1; i < pattern.size(); i++)
- {
- query.append(" or ");
- appendPattern(query, pattern.get(i).getQPathEntry(), true);
- }
- query.append(" ) and P.I_CLASS=2 and P.CONTAINER_NAME='");
- query.append(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'");
- query.append(" or
P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')");
- query.append(" and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID");
-
- return findNodesByParentIdAndComplexPatternCQ.executeQuery(query.toString());
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(2, parentIdentifier);
- return findPropertiesByParentIdCQ.executeQuery();
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildPropertiesByParentIdentifierCQ(String parentCid,
List<QPathEntryFilter> pattern)
- throws SQLException
- {
- if (pattern.isEmpty())
- {
- throw new SQLException("Pattern list is empty.");
- }
- else
- {
- if (findPropertiesByParentIdAndComplexPatternCQ == null)
- {
- findPropertiesByParentIdAndComplexPatternCQ =
dbConnection.createStatement();
- }
- //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("' and I.PARENT_ID='");
- query.append(parentCid);
- query.append("' and ( ");
- appendPattern(query, pattern.get(0).getQPathEntry(), false);
- for (int i = 1; i < pattern.size(); i++)
- {
- query.append(" or ");
- appendPattern(query, pattern.get(i).getQPathEntry(), false);
- }
- query.append(" ) order by I.NAME");
-
- return
findPropertiesByParentIdAndComplexPatternCQ.executeQuery(query.toString());
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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(2, parentIdentifier);
- return findNodeMainPropertiesByParentIdentifierCQ.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findNodesAndProperties(String lastNodeId, int offset, int limit)
throws SQLException
- {
- if (findNodesAndProperties == null)
- {
- findNodesAndProperties =
dbConnection.prepareStatement(FIND_NODES_AND_PROPERTIES);
- }
- else
- {
- findNodesAndProperties.clearParameters();
- }
-
- findNodesAndProperties.setString(1, containerName);
- findNodesAndProperties.setString(2, getInternalId(lastNodeId));
- findNodesAndProperties.setInt(3, limit);
- findNodesAndProperties.setInt(4, offset);
- findNodesAndProperties.setString(5, 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)
- {
- // [PN] store vd reference to external storage etc.
- updateValue.setNull(1, Types.BINARY);
- updateValue.setString(2, storageDesc);
- }
- else
- {
- updateValue.setBinaryStream(1, stream, streamLength);
- updateValue.setNull(2, Types.VARCHAR);
- }
-
- updateValue.setString(3, cid);
- updateValue.setInt(4, orderNumber);
- return updateValue.executeUpdate();
- }
-
- /**
- * Replace underscore in pattern with escaped symbol. Replace jcr-wildcard '*'
with sql-wildcard '%'.
- *
- * @param pattern
- * @return pattern with escaped underscore and fixed wildcard symbols
- */
- protected String fixEscapeSymbols(String pattern)
- {
- char[] chars = pattern.toCharArray();
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < chars.length; i++)
- {
- switch (chars[i])
- {
- case '*' :
- sb.append('%');
- break;
- case '_' :
- case '%' :
- sb.append(getWildcardEscapeSymbold());
- default :
- sb.append(chars[i]);
- }
- }
- return sb.toString();
- }
-
- /**
- * Append pattern expression.
- * Appends String "I.NAME LIKE 'escaped pattern' ESCAPE
'escapeString'" or "I.NAME='pattern'"
- * to String builder sb.
- *
- * @param sb StringBuilder
- * @param indexConstraint
- * @param pattern
- */
- protected void appendPattern(StringBuilder sb, QPathEntry entry, boolean
indexConstraint)
- {
- String pattern = entry.getAsString(false);
- sb.append("(I.NAME");
- if (pattern.contains("*"))
- {
- sb.append(" LIKE '");
- sb.append(fixEscapeSymbols(pattern));
- sb.append("' ESCAPE '");
- sb.append(getLikeExpressionEscape());
- sb.append("'");
- }
- else
- {
- sb.append("='");
- sb.append(pattern);
- sb.append("'");
- }
-
- if (indexConstraint && entry.getIndex() != -1)
- {
- sb.append(" and I.I_INDEX=");
- sb.append(entry.getIndex());
- }
- sb.append(")");
- }
-
- protected String getWildcardEscapeSymbold()
- {
- return PATTERN_ESCAPE_STRING;
- }
-
- protected String getLikeExpressionEscape()
- {
- return PATTERN_ESCAPE_STRING;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findACLHolders() throws SQLException
- {
- if (findACLHolders == null)
- {
- findACLHolders = dbConnection.prepareStatement(FIND_ACL_HOLDERS);
- }
- else
- {
- findACLHolders.clearParameters();
- }
-
- findACLHolders.setString(1, containerName);
-
- return findACLHolders.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- protected void deleteLockProperties() throws SQLException
- {
- PreparedStatement removeValuesStatement = null;
- PreparedStatement removeItemsStatement = null;
-
- try
- {
- removeValuesStatement =
- 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);
-
- 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);
-
- removeValuesStatement.executeUpdate();
- removeItemsStatement.executeUpdate();
- }
- finally
- {
- if (removeValuesStatement != null)
- {
- try
- {
- removeValuesStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
-
- if (removeItemsStatement != null)
- {
- try
- {
- removeItemsStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findNodesCount() throws SQLException
- {
- if (findNodesCount == null)
- {
- findNodesCount = dbConnection.prepareStatement(FIND_NODES_COUNT);
- }
- else
- {
- findNodesCount.clearParameters();
- }
-
- findNodesCount.setString(1, containerName);
-
- return findNodesCount.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- protected void deleteLockProperties(String nodeIdentifier) throws SQLException
- {
- PreparedStatement removeValuesStatement = null;
- PreparedStatement removeItemsStatement = null;
-
- try
- {
- removeValuesStatement =
- 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(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(2, getInternalId(nodeIdentifier));
-
- removeValuesStatement.executeUpdate();
- removeItemsStatement.executeUpdate();
- }
- finally
- {
- if (removeValuesStatement != null)
- {
- try
- {
- removeValuesStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
-
- if (removeItemsStatement != null)
- {
- try
- {
- removeItemsStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
- }
- }
-}
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-14
09:31:09 UTC (rev 5862)
+++
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-14
13:28:03 UTC (rev 5863)
@@ -19,11 +19,8 @@
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;
-import java.io.File;
import java.sql.SQLException;
import javax.jcr.RepositoryException;
@@ -41,14 +38,6 @@
{
/**
- * SybaseConnectionFactory constructor.
- */
- public SybaseConnectionFactory(JDBCDataContainerConfig containerConfig) throws
RepositoryException
- {
- super(containerConfig);
- }
-
- /**
* SybaseConnectionFactory constructor.
*/
public SybaseConnectionFactory(DataSource dbDataSource, JDBCDataContainerConfig
containerConfig)
@@ -64,7 +53,7 @@
{
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new SybaseMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
}
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-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -18,15 +18,13 @@
*/
package org.exoplatform.services.jcr.impl.util.jdbc;
-import org.exoplatform.commons.utils.IOUtil;
-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.Constants;
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;
@@ -52,17 +50,17 @@
static public String SQL_CREATEVIEW =
"^(CREATE(\\s)+VIEW(\\s)+(IF(\\s)+NOT(\\s)+EXISTS(\\s)+)*){1}";
- static public String SQL_OBJECTNAME =
"((JCR_[A-Z_]+){1}(\\s*?|(\\(\\))*?)+)+?";
+ static public String SQL_OBJECTNAME =
"((JCR_[A-Z_0-9]+){1}(\\s*?|(\\(\\))*?)+)+?";
static public String SQL_CREATEINDEX =
"^(CREATE(\\s)+(UNIQUE(\\s)+)*INDEX(\\s)+){1}";
- static public String SQL_ONTABLENAME =
"(ON(\\s)+(JCR_[A-Z_]+){1}(\\s*?|(\\(\\))*?)+){1}";
+ static public String SQL_ONTABLENAME =
"(ON(\\s)+(JCR_[A-Z_0-9]+){1}(\\s*?|(\\(\\))*?)+){1}";
static public String SQL_CREATESEQUENCE =
"^(CREATE(\\s)+SEQUENCE(\\s)+){1}";
static public String SQL_CREATETRIGGER =
"^(CREATE(\\s)+(OR(\\s){1}REPLACE(\\s)+)*TRIGGER(\\s)+){1}";
- static public String SQL_TRIGGERNAME =
"(([A-Z_]+JCR_[A-Z_]+){1}(\\s*?|(\\(\\))*?)+)+?";
+ static public String SQL_TRIGGERNAME =
"(([A-Z_]+JCR_[A-Z_0-9]+){1}(\\s*?|(\\(\\))*?)+)+?";
protected static final Log LOG =
ExoLogger.getLogger("exo.jcr.component.core.DBInitializer");
@@ -92,7 +90,7 @@
{
this.connection = connection;
this.containerConfig = containerConfig;
- this.script = prepareScripts();
+ this.script = DBInitializerHelper.prepareScripts(containerConfig);
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);
@@ -103,11 +101,6 @@
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>()
@@ -352,9 +345,18 @@
}
/**
- * Place to perform additional operations in overriden classes.
+ * Init root node parent record.
*/
protected void postInit(Connection connection) throws SQLException
{
+ String select =
+ "select * from " +
DBInitializerHelper.getItemTableName(containerConfig) + " where ID='"
+ + Constants.ROOT_PARENT_UUID + "' and PARENT_ID='" +
Constants.ROOT_PARENT_UUID + "'";
+
+ if (!connection.createStatement().executeQuery(select).next())
+ {
+ 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/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-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializerHelper.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -18,11 +18,15 @@
import org.exoplatform.commons.utils.IOUtil;
import org.exoplatform.commons.utils.PrivilegedFileHelper;
+import org.exoplatform.services.database.utils.DialectConstants;
import org.exoplatform.services.database.utils.JDBCUtils;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
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.jcr.impl.storage.jdbc.JDBCDataContainerConfig.DatabaseStructureType;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -44,45 +48,102 @@
protected final static Log LOG =
ExoLogger.getLogger("exo.jcr.component.core.DBInitializerHelper");
/**
- * Getting path to initialization by specific dialect and multidb.
+ * Table prefix for all tables used in JCR.
+ */
+ public static final String JCR_TABLE_PREFIX = "JCR_";
+
+ /**
+ * Returns SQL scripts for initialization database for defined {@link
JDBCDataContainerConfig}.
+ */
+ public static String prepareScripts(JDBCDataContainerConfig containerConfig) throws
IOException
+ {
+ String itemTableSuffix = getItemTableSuffix(containerConfig);
+ String valueTableSuffix = getValueTableSuffix(containerConfig);
+ String refTableSuffix = getRefTableSuffix(containerConfig);
+
+ boolean isolatedDB = containerConfig.dbStructureType ==
DatabaseStructureType.ISOLATED;
+
+ return prepareScripts(containerConfig.initScriptPath, itemTableSuffix,
valueTableSuffix, refTableSuffix, isolatedDB);
+ }
+
+ /**
+ * Returns SQL scripts for initialization database for defined {@link WorkspaceEntry}.
*
- * @param dbDialect
- * String
- * @param multiDb
- * Boolean
- * @return String
- * Path to DB initialization script.
+ * @param wsEntry
+ * workspace configuration
+ * @param dialect
+ * database dialect which is used, since {@link
JDBCWorkspaceDataContainer#DB_DIALECT} parameter
+ * can contain {@link DialectConstants#DB_DIALECT_AUTO} value it is necessary
to resolve dialect
+ * before based on database connection.
*/
+ public static String prepareScripts(WorkspaceEntry wsEntry, String dialect) throws
IOException,
+ RepositoryConfigurationException
+ {
+ String itemTableSuffix = getItemTableSuffix(wsEntry);
+ String valueTableSuffix = getValueTableSuffix(wsEntry);
+ String refTableSuffix = getRefTableSuffix(wsEntry);
+
+ DatabaseStructureType dbType =
JDBCWorkspaceDataContainer.getDatabaseType(wsEntry);
+
+ boolean isolatedDB = dbType == DatabaseStructureType.ISOLATED;
+ String initScriptPath = DBInitializerHelper.scriptPath(dialect,
dbType.isMultiDatabase());
+
+ return prepareScripts(initScriptPath, itemTableSuffix, valueTableSuffix,
refTableSuffix, isolatedDB);
+ }
+
+ /**
+ * Preparing SQL scripts for database initialization.
+ */
+ private static String prepareScripts(String initScriptPath, String itemTableSuffix,
String valueTableSuffix,
+ String refTableSuffix, boolean isolatedDB) throws IOException
+ {
+ String scripts =
IOUtil.getStreamContentAsString(PrivilegedFileHelper.getResourceAsStream(initScriptPath));
+
+ if (isolatedDB)
+ {
+ scripts =
+ scripts.replace("MITEM",
itemTableSuffix).replace("MVALUE", valueTableSuffix)
+ .replace("MREF", refTableSuffix);
+ }
+
+ return scripts;
+ }
+
+ /**
+ * Returns path where SQL scripts for database initialization is stored.
+ */
public static String scriptPath(String dbDialect, boolean multiDb)
{
+ String suffix = multiDb ? "m" : "s";
+
String sqlPath = null;
if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLEOCI))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.ora.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.ora.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLE))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.ora.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.ora.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_PGSQL))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.pgsql.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.pgsql.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MYSQL))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.mysql.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.mysql.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MYSQL_MYISAM))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.mysql-myisam.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix +
"jdbc.mysql-myisam.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MYSQL_UTF8))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.mysql-utf8.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix +
"jdbc.mysql-utf8.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MYSQL_MYISAM_UTF8))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.mysql-myisam-utf8.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix +
"jdbc.mysql-myisam-utf8.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MSSQL))
{
@@ -90,111 +151,163 @@
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_DERBY))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.derby.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.derby.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_DB2))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.db2.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.db2.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_DB2V8))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.db2v8.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.db2v8.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.sybase.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix +
"jdbc.sybase.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_INGRES))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.ingres.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix +
"jdbc.ingres.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_HSQLDB))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.sql";
}
else
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.sql";
}
return sqlPath;
}
/**
- * Initialization script for root node.
- *
+ * Initialization script for root node based on {@link JDBCDataContainerConfig}.
*/
public static String getRootNodeInitializeScript(JDBCDataContainerConfig
containerConfig)
{
- // no ContainerNamer required
- boolean simpleTable = containerConfig.dbStructureType.isSimpleTable();
+ boolean multiDb = containerConfig.dbStructureType.isMultiDatabase();
+ String itemTableName = getItemTableName(containerConfig);
- 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)";
+ return getRootNodeInitializeScript(itemTableName, multiDb);
}
/**
* 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)
+ public static String getRootNodeInitializeScript(String itemTableName, 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('"
- + Constants.ROOT_PARENT_UUID + "', '" +
Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_NAME
- + "', " + (multiDb ? "" : "'" +
Constants.ROOT_PARENT_CONAINER_NAME + "', ") + "0, 0, 0, 0)";
+ String singeDbScript =
+ "insert into " + itemTableName + "(ID, PARENT_ID, NAME,
CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, "
+ + "N_ORDER_NUM) VALUES('" + Constants.ROOT_PARENT_UUID +
"', '" + Constants.ROOT_PARENT_UUID + "', '"
+ + Constants.ROOT_PARENT_NAME + "', '" +
Constants.ROOT_PARENT_CONAINER_NAME + "', 0, 0, 0, 0)";
+
+ String multiDbScript =
+ "insert into " + itemTableName + "(ID, PARENT_ID, NAME, VERSION,
I_CLASS, I_INDEX, " + "N_ORDER_NUM) VALUES('"
+ + Constants.ROOT_PARENT_UUID + "', '" +
Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_NAME
+ + "', 0, 0, 0, 0)";
+
+ return multiDb ? multiDbScript : singeDbScript;
}
- public static String getTableSuffix(JDBCDataContainerConfig containerConfig)
+ public static String getItemTableSuffix(WorkspaceEntry wsConfig) throws
RepositoryConfigurationException
{
+ return getTableSuffix(JDBCWorkspaceDataContainer.getDatabaseType(wsConfig),
+ JDBCWorkspaceDataContainer.getDBTableSuffix(wsConfig), "ITEM");
+ }
+
+ public static String getValueTableSuffix(WorkspaceEntry wsConfig) throws
RepositoryConfigurationException
+ {
+ return getTableSuffix(JDBCWorkspaceDataContainer.getDatabaseType(wsConfig),
+ JDBCWorkspaceDataContainer.getDBTableSuffix(wsConfig), "VALUE");
+ }
+
+ public static String getRefTableSuffix(WorkspaceEntry wsConfig) throws
RepositoryConfigurationException
+ {
+ return getTableSuffix(JDBCWorkspaceDataContainer.getDatabaseType(wsConfig),
+ JDBCWorkspaceDataContainer.getDBTableSuffix(wsConfig), "REF");
+ }
+
+ public static String getItemTableName(WorkspaceEntry wsConfig) throws
RepositoryConfigurationException
+ {
+ return JCR_TABLE_PREFIX
+ + getTableSuffix(JDBCWorkspaceDataContainer.getDatabaseType(wsConfig),
+ JDBCWorkspaceDataContainer.getDBTableSuffix(wsConfig), "ITEM");
+ }
+
+ public static String getValueTableName(WorkspaceEntry wsConfig) throws
RepositoryConfigurationException
+ {
+ return JCR_TABLE_PREFIX
+ + getTableSuffix(JDBCWorkspaceDataContainer.getDatabaseType(wsConfig),
+ JDBCWorkspaceDataContainer.getDBTableSuffix(wsConfig), "VALUE");
+ }
+
+ public static String getRefTableName(WorkspaceEntry wsConfig) throws
RepositoryConfigurationException
+ {
+ return JCR_TABLE_PREFIX
+ + getTableSuffix(JDBCWorkspaceDataContainer.getDatabaseType(wsConfig),
+ JDBCWorkspaceDataContainer.getDBTableSuffix(wsConfig), "REF");
+ }
+
+ public static String getItemTableSuffix(JDBCDataContainerConfig containerConfig)
+ {
+ return getTableSuffix(containerConfig.dbStructureType,
containerConfig.dbTableSuffix, "ITEM");
+ }
+
+ public static String getValueTableSuffix(JDBCDataContainerConfig containerConfig)
+ {
+ return getTableSuffix(containerConfig.dbStructureType,
containerConfig.dbTableSuffix, "VALUE");
+ }
+
+ public static String getRefTableSuffix(JDBCDataContainerConfig containerConfig)
+ {
+ return getTableSuffix(containerConfig.dbStructureType,
containerConfig.dbTableSuffix, "REF");
+ }
+
+ public static String getItemTableName(JDBCDataContainerConfig containerConfig)
+ {
+ return JCR_TABLE_PREFIX + getTableSuffix(containerConfig.dbStructureType,
containerConfig.dbTableSuffix, "ITEM");
+ }
+
+ public static String getValueTableName(JDBCDataContainerConfig containerConfig)
+ {
+ return JCR_TABLE_PREFIX + getTableSuffix(containerConfig.dbStructureType,
containerConfig.dbTableSuffix, "VALUE");
+ }
+
+ public static String getRefTableName(JDBCDataContainerConfig containerConfig)
+ {
+ return JCR_TABLE_PREFIX + getTableSuffix(containerConfig.dbStructureType,
containerConfig.dbTableSuffix, "REF");
+ }
+
+ private static String getTableSuffix(JDBCDataContainerConfig.DatabaseStructureType
dbType, String dbTableSuffix,
+ String forTable)
+ {
String tableSuffix = "";
- switch (containerConfig.dbStructureType)
+ switch (dbType)
{
case MULTI :
- tableSuffix = "MITEM";
+ tableSuffix = "M" + forTable;
break;
case SINGLE :
- tableSuffix = "SITEM";
+ tableSuffix = "S" + forTable;
break;
case ISOLATED :
- tableSuffix = "I" + containerConfig.dbTableSuffix;
+ tableSuffix = forTable.substring(0, 1) + 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
+ * Returns SQL script for create objects such as index, primary of foreign key.
*/
- public static String getObjectScript(String objectName, boolean multiDb, String
dialect)
- throws RepositoryConfigurationException
+ public static String getObjectScript(String objectName, boolean multiDb, String
dialect, WorkspaceEntry wsEntry)
+ throws RepositoryConfigurationException, IOException
{
- String scriptsPath = DBInitializerHelper.scriptPath(dialect, multiDb);
- String script;
- try
- {
- script =
IOUtil.getStreamContentAsString(PrivilegedFileHelper.getResourceAsStream(scriptsPath));
- }
- catch (IOException e)
- {
- throw new RepositoryConfigurationException("Can not read script file "
+ scriptsPath, e);
- }
+ String scripts = prepareScripts(wsEntry, dialect);
String sql = null;
- for (String query : JDBCUtils.splitWithSQLDelimiter(script))
+ for (String query : JDBCUtils.splitWithSQLDelimiter(scripts))
{
String q = JDBCUtils.cleanWhitespaces(query);
if (q.contains(objectName))
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-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSVNodeDataOptimization.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -258,7 +258,7 @@
try
{
DatabaseStructureType databaseType =
JDBCWorkspaceDataContainer.getDatabaseType(ws1e);
- return !databaseType.isSingleDatabase();
+ return databaseType.isMultiDatabase();
}
catch (RepositoryConfigurationException e)
{
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceRestore.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceRestore.java 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceRestore.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -23,6 +23,7 @@
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.core.ManageableRepository;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.util.TesterConfigurationHelper;
import java.io.BufferedInputStream;
@@ -57,7 +58,7 @@
super.setUp();
wsEntry =
(WorkspaceEntry)session.getContainer().getComponentInstanceOfType(WorkspaceEntry.class);
- isDefaultWsMultiDb =
"true".equals(wsEntry.getContainer().getParameterValue("multi-db"));
+ isDefaultWsMultiDb =
JDBCWorkspaceDataContainer.getDatabaseType(wsEntry).isMultiDatabase();
}
public void testRestore() throws RepositoryConfigurationException, Exception
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-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -19,7 +19,7 @@
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 org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
import java.sql.SQLException;
import java.sql.Statement;
@@ -43,7 +43,7 @@
containerConfig.initScriptPath = scriptPath;
containerConfig.dbStructureType = multiDB ? DatabaseStructureType.MULTI :
DatabaseStructureType.SINGLE;
containerConfig.multiDb = multiDB;
- new StorageDBInitializer(getJNDIConnection(), containerConfig).init();
+ new DBInitializer(getJNDIConnection(), containerConfig).init();
}
@Override
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-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -19,7 +19,7 @@
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 org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
import java.sql.SQLException;
import java.sql.Statement;
@@ -43,7 +43,7 @@
containerConfig.initScriptPath = scriptPath;
containerConfig.dbStructureType = multiDB ? DatabaseStructureType.MULTI :
DatabaseStructureType.SINGLE;
containerConfig.multiDb = multiDB;
- new StorageDBInitializer(getJNDIConnection(), containerConfig).init();
+ new DBInitializer(getJNDIConnection(), containerConfig).init();
}
@Override
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-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/export/ExportWorkspaceSystemViewTest.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -163,7 +163,7 @@
try
{
DatabaseStructureType databaseType =
JDBCWorkspaceDataContainer.getDatabaseType(ws1e);
- return !databaseType.isSingleDatabase();
+ return databaseType.isMultiDatabase();
}
catch (RepositoryConfigurationException e)
{
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -91,8 +91,7 @@
// define one common database cleaner for all restores for single db case
DBCleanerTool dbCleaner = null;
- Boolean isMultiDb =
-
Boolean.parseBoolean(wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.MULTIDB));
+ Boolean isMultiDb =
JDBCWorkspaceDataContainer.getDatabaseType(wsEntry).isMultiDatabase();
if (!isMultiDb)
{
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingWorkspaceSameConfigRestore.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingWorkspaceSameConfigRestore.java 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingWorkspaceSameConfigRestore.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -30,6 +30,7 @@
import org.exoplatform.services.jcr.impl.backup.JCRRestore;
import org.exoplatform.services.jcr.impl.backup.rdbms.DataRestoreContext;
import
org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.impl.util.io.FileCleanerHolder;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -78,7 +79,7 @@
{
ManageableRepository repository =
repositoryService.getRepository(repositoryName);
- if (wEntry.getContainer().getParameterBoolean("multi-db") == false)
+ if (!JDBCWorkspaceDataContainer.getDatabaseType(wEntry).isMultiDatabase())
{
for (String wsName : repository.getWorkspaceNames())
{
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/RdbmsWorkspaceInitializer.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/RdbmsWorkspaceInitializer.java 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/RdbmsWorkspaceInitializer.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -35,6 +35,7 @@
import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeManagerImpl;
import org.exoplatform.services.jcr.impl.core.value.ValueFactoryImpl;
import
org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.impl.util.io.FileCleanerHolder;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -104,7 +105,7 @@
try
{
// set state SUSPENDED to other workspaces if singledb
- if (workspaceEntry.getContainer().getParameterBoolean("multi-db") ==
false)
+ if
(!JDBCWorkspaceDataContainer.getDatabaseType(workspaceEntry).isMultiDatabase())
{
for (WorkspaceEntry we : repositoryEntry.getWorkspaceEntries())
{
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/usecase/TestBackupRestore.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/usecase/TestBackupRestore.java 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/usecase/TestBackupRestore.java 2012-03-14
13:28:03 UTC (rev 5863)
@@ -45,6 +45,7 @@
import org.exoplatform.services.jcr.impl.core.SessionImpl;
import org.exoplatform.services.jcr.impl.core.SessionRegistry;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
+import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;
import java.io.File;
import java.sql.Connection;
@@ -883,7 +884,9 @@
ManageableRepository repository = repositoryService.getRepository(repositoryName);
for (WorkspaceEntry wsEntry : repository.getConfiguration().getWorkspaceEntries())
{
- String multiDb =
wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB) ?
"M" : "S";
+ String itemTableName = DBInitializerHelper.getItemTableName(wsEntry);
+ String valueTableName = DBInitializerHelper.getValueTableName(wsEntry);
+ String refTableName = DBInitializerHelper.getRefTableName(wsEntry);
DataSource ds =
(DataSource)new
InitialContext().lookup(wsEntry.getContainer().getParameterValue(
@@ -891,7 +894,7 @@
Connection conn = ds.getConnection();
try
{
- ResultSet result = conn.createStatement().executeQuery("SELECT COUNT(*)
FROM JCR_" + multiDb + "ITEM");
+ ResultSet result = conn.createStatement().executeQuery("SELECT COUNT(*)
FROM " + itemTableName);
try
{
assertTrue(result.next());
@@ -902,7 +905,7 @@
result.close();
}
- result = conn.createStatement().executeQuery("SELECT COUNT(*) FROM
JCR_" + multiDb + "VALUE");
+ result = conn.createStatement().executeQuery("SELECT COUNT(*) FROM
" + valueTableName);
try
{
assertTrue(result.next());
@@ -913,7 +916,7 @@
result.close();
}
- result = conn.createStatement().executeQuery("SELECT COUNT(*) FROM
JCR_" + multiDb + "REF");
+ result = conn.createStatement().executeQuery("SELECT COUNT(*) FROM
" + refTableName);
try
{
assertTrue(result.next());
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config-backup.xml
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config-backup.xml 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config-backup.xml 2012-03-14
13:28:03 UTC (rev 5863)
@@ -29,7 +29,7 @@
<container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr6"
/>
- <property name="multi-db" value="false"
/>
+ <property name="db-structure-type"
value="single" />
<property name="max-buffer-size" value="200k"
/>
<property name="swap-directory"
value="target/temp/swap/db3ws" />
</properties>
@@ -81,7 +81,7 @@
<container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr6"
/>
- <property name="multi-db" value="false"
/>
+ <property name="db-structure-type"
value="single" />
<property name="max-buffer-size" value="200k"
/>
<property name="swap-directory"
value="target/temp/swap/db3ws1" />
</properties>
@@ -140,7 +140,7 @@
<container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr7"
/>
- <property name="multi-db" value="true" />
+ <property name="db-structure-type"
value="isolated" />
<property name="max-buffer-size" value="200k"
/>
<property name="swap-directory"
value="target/temp/swap/db4ws" />
</properties>
@@ -192,7 +192,7 @@
<container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr8"
/>
- <property name="multi-db" value="true" />
+ <property name="db-structure-type"
value="isolated" />
<property name="max-buffer-size" value="200k"
/>
<property name="swap-directory"
value="target/temp/swap/db4ws1" />
</properties>
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml 2012-03-14
13:28:03 UTC (rev 5863)
@@ -321,7 +321,7 @@
<container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr6"
/>
- <property name="multi-db" value="false"
/>
+ <property name="db-structure-type"
value="single" />
<property name="max-buffer-size" value="200k"
/>
<property name="swap-directory"
value="target/temp/swap/db3ws" />
</properties>
@@ -373,7 +373,7 @@
<container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr6"
/>
- <property name="multi-db" value="false"
/>
+ <property name="db-structure-type"
value="single" />
<property name="max-buffer-size" value="200k"
/>
<property name="swap-directory"
value="target/temp/swap/db3ws1" />
</properties>
@@ -432,7 +432,7 @@
<container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr7"
/>
- <property name="multi-db" value="true" />
+ <property name="db-structure-type"
value="isolated" />
<property name="max-buffer-size" value="200k"
/>
<property name="swap-directory"
value="target/temp/swap/db4ws" />
</properties>
@@ -484,7 +484,7 @@
<container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr8"
/>
- <property name="multi-db" value="true" />
+ <property name="db-structure-type"
value="isolated" />
<property name="max-buffer-size" value="200k"
/>
<property name="swap-directory"
value="target/temp/swap/db4ws1" />
</properties>
Modified:
jcr/branches/1.15.x/exo.jcr.component.ftp/src/test/resources/conf/standalone/test-jcr-config.xml
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.ftp/src/test/resources/conf/standalone/test-jcr-config.xml 2012-03-14
09:31:09 UTC (rev 5862)
+++
jcr/branches/1.15.x/exo.jcr.component.ftp/src/test/resources/conf/standalone/test-jcr-config.xml 2012-03-14
13:28:03 UTC (rev 5863)
@@ -29,8 +29,8 @@
<!-- for system storage -->
<container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
- <property name="sourceName" value="jdbcjcr"
/>
- <property name="dialect" value="generic"
/>
+ <property name="source-name" value="jdbcjcr"
/>
+ <property name="dialect" value="auto" />
<property name="multi-db" value="false"
/>
<property name="max-buffer-size"
value="204800" />
<property name="swap-directory"
value="target/temp/swap/ws" />
@@ -68,8 +68,8 @@
<!-- for system storage -->
<container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
- <property name="sourceName" value="jdbcjcr"
/>
- <property name="dialect" value="generic"
/>
+ <property name="source-name" value="jdbcjcr"
/>
+ <property name="dialect" value="auto" />
<property name="multi-db" value="false"
/>
<property name="max-buffer-size"
value="204800" />
<property name="swap-directory"
value="target/temp/swap/ws2" />