Author: sergiykarpenko
Date: 2011-03-16 12:39:17 -0400 (Wed, 16 Mar 2011)
New Revision: 4101
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java
Log:
EXOJCR-1210: DBCleanService - MySQL non-MyISAM engined catalogs will be cleaned with clean
helper.
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java 2011-03-16
14:12:31 UTC (rev 4100)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java 2011-03-16
16:39:17 UTC (rev 4101)
@@ -27,7 +27,9 @@
import java.security.PrivilegedExceptionAction;
import java.sql.Connection;
+import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
@@ -127,16 +129,33 @@
Boolean.parseBoolean(wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.MULTIDB));
String containerName = wsEntry.getName();
-
String dialect = DialectDetecter.detect(jdbcConn.getMetaData());
+ boolean cleanWithHelper = false;
+ if (dialect.equals(DBConstants.DB_DIALECT_MYSQL) ||
dialect.equals(DBConstants.DB_DIALECT_MYSQL_UTF8))
+ {
+ cleanWithHelper = true;
+ Statement st = jdbcConn.createStatement();
+ st.execute("SELECT ENGINE FROM information_schema.TABLES where
TABLE_SCHEMA='" + jdbcConn.getCatalog()
+ + "' and (TABLE_NAME='JCR_SITEM' or
TABLE_NAME='JCR_MITEM')");
+ ResultSet result = st.getResultSet();
+ if (result.next())
+ {
+ String engine = result.getString(1);
+ if (engine.equalsIgnoreCase("MyISAM"))
+ {
+ cleanWithHelper = false;
+ }
+ }
+ }
+
List<String> cleanScripts = new ArrayList<String>();
if (multiDb)
{
cleanScripts.add("delete from JCR_MVALUE");
cleanScripts.add("delete from JCR_MREF");
- if (dialect.equals(DBConstants.DB_DIALECT_HSQLDB))
+ if (dialect.equals(DBConstants.DB_DIALECT_HSQLDB) || cleanWithHelper)
{
cleanScripts.add("delete from JCR_MITEM where I_CLASS=2");
@@ -157,7 +176,7 @@
.add("delete from JCR_SREF where exists(select * from JCR_SITEM where
JCR_SITEM.ID=JCR_SREF.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME='"
+ containerName + "')");
- if (dialect.equals(DBConstants.DB_DIALECT_HSQLDB))
+ if (dialect.equals(DBConstants.DB_DIALECT_HSQLDB) || cleanWithHelper)
{
cleanScripts.add("delete from JCR_SITEM where I_CLASS=2 and
CONTAINER_NAME='" + containerName + "'");
Show replies by date