Author: sergiykarpenko
Date: 2010-09-17 04:20:10 -0400 (Fri, 17 Sep 2010)
New Revision: 3129
Added:
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-mjdbc.mysql-utf8.sql
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-mjdbc.mysql.sql
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-mjdbc.pgsql.sql
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-sjdbc.mysql-utf8.sql
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-sjdbc.mysql.sql
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-sjdbc.pgsql.sql
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBCleanerService.java
Log:
EXOJCR-939: scripts added
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBCleanerService.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBCleanerService.java 2010-09-17
07:05:17 UTC (rev 3128)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBCleanerService.java 2010-09-17
08:20:10 UTC (rev 3129)
@@ -19,6 +19,7 @@
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.RepositoryEntry;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -69,7 +70,7 @@
throw new RepositoryException(err, e);
}
- final String sqlPath = "/conf/storage/cleanup/jcr-" +
(wsJDBCConfig.isMultiDb() ? "m" : "s") + "jdbc.sql";
+ final String sqlPath = getScriptPath(wsJDBCConfig.getDbDialect(),
wsJDBCConfig.isMultiDb());
PrivilegedAction<InputStream> action = new
PrivilegedAction<InputStream>()
{
public InputStream run()
@@ -107,4 +108,65 @@
removeWorkspaceData(wsEntry);
}
}
+
+ private static String getScriptPath(String dbDialect, boolean multiDb)
+ {
+ String sqlPath = "/conf/storage/cleanup/jcr-" + (multiDb ? "m"
: "s");
+ if (dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
+ {
+ LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is
experimental!");
+ sqlPath = sqlPath + "jdbc.ora.sql";
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_ORACLE)
+ {
+ sqlPath = sqlPath + "jdbc.ora.sql";
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_PGSQL)
+ {
+ sqlPath = sqlPath + "jdbc.pgsql.sql";
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_MYSQL)
+ {
+ sqlPath = sqlPath + "jdbc.mysql.sql";
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_MYSQL_UTF8)
+ {
+ sqlPath = sqlPath + "jdbc.mysql-utf8.sql";
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_MSSQL)
+ {
+ sqlPath = sqlPath + "jdbc.mssql.sql";
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_DERBY)
+ {
+ sqlPath = sqlPath + "jdbc.derby.sql";
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_DB2)
+ {
+ sqlPath = sqlPath + "jdbc.db2.sql";
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_DB2V8)
+ {
+ sqlPath = sqlPath + "jdbc.db2v8.sql";
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_SYBASE)
+ {
+ sqlPath = sqlPath + "jdbc.sybase.sql";
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_INGRES)
+ {
+ sqlPath = sqlPath + "jdbc.ingres.sql";
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_HSQLDB)
+ {
+ sqlPath = sqlPath + "jdbc.sql";
+ }
+ else
+ {
+ // generic, DB_HSQLDB
+ sqlPath = sqlPath + "jdbc.sql";
+ }
+ return sqlPath;
+ }
+
}
Added:
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-mjdbc.mysql-utf8.sql
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-mjdbc.mysql-utf8.sql
(rev 0)
+++
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-mjdbc.mysql-utf8.sql 2010-09-17
08:20:10 UTC (rev 3129)
@@ -0,0 +1,3 @@
+DROP TABLE JCR_MREF;
+DROP TABLE JCR_MVALUE;
+DROP TABLE JCR_MITEM;
Added:
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-mjdbc.mysql.sql
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-mjdbc.mysql.sql
(rev 0)
+++
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-mjdbc.mysql.sql 2010-09-17
08:20:10 UTC (rev 3129)
@@ -0,0 +1,3 @@
+DROP TABLE JCR_MREF;
+DROP TABLE JCR_MVALUE;
+DROP TABLE JCR_MITEM;
Added:
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-mjdbc.pgsql.sql
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-mjdbc.pgsql.sql
(rev 0)
+++
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-mjdbc.pgsql.sql 2010-09-17
08:20:10 UTC (rev 3129)
@@ -0,0 +1,3 @@
+DROP TABLE JCR_MREF;
+DROP TABLE JCR_MVALUE;
+DROP TABLE JCR_MITEM;
Added:
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-sjdbc.mysql-utf8.sql
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-sjdbc.mysql-utf8.sql
(rev 0)
+++
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-sjdbc.mysql-utf8.sql 2010-09-17
08:20:10 UTC (rev 3129)
@@ -0,0 +1,5 @@
+delete from JCR_SVALUE where exists(select * from JCR_SITEM where
JCR_SITEM.ID=JCR_SVALUE.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
+delete from JCR_SREF where exists(select * from JCR_SITEM where
JCR_SITEM.ID=JCR_SREF.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
+delete from JCR_SITEM where I_CLASS=2 and CONTAINER_NAME=?;
+/*$CLEAN_JCR_SITEM_DEFAULT*/;
+
Added:
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-sjdbc.mysql.sql
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-sjdbc.mysql.sql
(rev 0)
+++
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-sjdbc.mysql.sql 2010-09-17
08:20:10 UTC (rev 3129)
@@ -0,0 +1,5 @@
+delete from JCR_SVALUE where exists(select * from JCR_SITEM where
JCR_SITEM.ID=JCR_SVALUE.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
+delete from JCR_SREF where exists(select * from JCR_SITEM where
JCR_SITEM.ID=JCR_SREF.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
+delete from JCR_SITEM where I_CLASS=2 and CONTAINER_NAME=?;
+/*$CLEAN_JCR_SITEM_DEFAULT*/;
+
Added:
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-sjdbc.pgsql.sql
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-sjdbc.pgsql.sql
(rev 0)
+++
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/jcr-sjdbc.pgsql.sql 2010-09-17
08:20:10 UTC (rev 3129)
@@ -0,0 +1,3 @@
+delete from JCR_SVALUE where exists(select * from JCR_SITEM where
JCR_SITEM.ID=JCR_SVALUE.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
+delete from JCR_SREF where exists(select * from JCR_SITEM where
JCR_SITEM.ID=JCR_SREF.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
+delete from JCR_SITEM where CONTAINER_NAME=?;
\ No newline at end of file
Show replies by date