[exo-jcr-commits] exo-jcr SVN: r5450 - in jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: clean/rdbms and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Jan 13 04:39:02 EST 2012


Author: tolusha
Date: 2012-01-13 04:39:01 -0500 (Fri, 13 Jan 2012)
New Revision: 5450

Removed:
   jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanHelper.java
   jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/RecursiveDBCleanHelper.java
Modified:
   jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DBRestore.java
   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/DBCleaner.java
   jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DummyDBCleaner.java
Log:
EXOJCR-1707: DBCleanHelper removed

Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DBRestore.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DBRestore.java	2012-01-13 08:22:15 UTC (rev 5449)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DBRestore.java	2012-01-13 09:39:01 UTC (rev 5450)
@@ -195,15 +195,7 @@
    {
       try
       {
-         try
-         {
-            // don't care about any exception here
-            dbCleaner.executeCommitScripts();
-         }
-         catch (Exception e)
-         {
-            LOG.error("Can't remove temporary objects after cleaning", e);
-         }
+         dbCleaner.executeCommitScripts();
 
          jdbcConn.commit();
       }

Deleted: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanHelper.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanHelper.java	2012-01-13 08:22:15 UTC (rev 5449)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanHelper.java	2012-01-13 09:39:01 UTC (rev 5450)
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2003-2011 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.clean.rdbms;
-
-import java.sql.SQLException;
-
-/**
- * Created by The eXo Platform SAS.
- * 
- * <br/>Date: 2011
- *
- * @author <a href="mailto:alex.reshetnyak at exoplatform.com.ua">Alex Reshetnyak</a> 
- * @version $Id: DBCleanHelper.java 111 2011-11-11 11:11:11Z rainf0x $
- */
-public interface DBCleanHelper
-{
-   /**
-    * Clean data from database. The method doesn't close connection or perform commit.
-    * 
-    * @throws SQLException
-    *          if any errors occurred 
-    */
-   public void executeCleanScripts() throws SQLException;
-}

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-01-13 08:22:15 UTC (rev 5449)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java	2012-01-13 09:39:01 UTC (rev 5450)
@@ -34,9 +34,7 @@
 import java.io.IOException;
 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;
 
@@ -869,32 +867,6 @@
 
       if (!isMultiDB)
       {
-         boolean cleanWithHelper = false;
-         if (dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_HSQLDB))
-         {
-            cleanWithHelper = true;
-         }
-         else if (dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MYSQL)
-            || dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MYSQL_UTF8)
-            || dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MYSQL_MYISAM)
-            || dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MYSQL_MYISAM_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("ENGINE");
-               if (engine.equalsIgnoreCase("MyISAM"))
-               {
-                  cleanWithHelper = false;
-               }
-            }
-         }
-
          String containerName = wsEntry.getName();
          String multiDb = isMultiDB ? "M" : "S";
 
@@ -923,21 +895,8 @@
                + containerName + "')");
          cleanScripts.add("delete from JCR_SREF where PROPERTY_ID IN (select ID from JCR_SITEM where CONTAINER_NAME='"
             + containerName + "')");
-
-         if (cleanWithHelper)
-         {
-            cleanScripts.add("delete from JCR_SITEM where I_CLASS=2 and CONTAINER_NAME='" + containerName + "'");
-
-            String selectItems =
-               "select ID from JCR_SITEM where I_CLASS=1 and CONTAINER_NAME='" + containerName + "' and PARENT_ID=?";
-            String deleteItems =
-               "delete from JCR_SITEM where I_CLASS=1 and CONTAINER_NAME='" + containerName + "' and PARENT_ID=?";
-
-            return new DBCleaner(jdbcConn, cleanScripts, rollbackScripts, commitScripts, new RecursiveDBCleanHelper(
-               jdbcConn, selectItems, deleteItems), dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE));
-         }
-
          cleanScripts.add("delete from JCR_SITEM where CONTAINER_NAME='" + containerName + "'");
+
          return new DBCleaner(jdbcConn, cleanScripts, rollbackScripts, commitScripts,
             dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE));
       }
@@ -980,16 +939,8 @@
       try
       {
          dbCleaner.executeCleanScripts();
+         dbCleaner.executeCommitScripts();
 
-         try
-         {
-            dbCleaner.executeCommitScripts();
-         }
-         catch (SQLException e)
-         {
-            LOG.error("Can't remove temporary objects", e);
-         }
-
          jdbcConn.commit();
       }
       catch (SQLException e)

Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleaner.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleaner.java	2012-01-13 08:22:15 UTC (rev 5449)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleaner.java	2012-01-13 09:39:01 UTC (rev 5450)
@@ -30,7 +30,7 @@
 import java.util.List;
 
 /**
- * The goal of this class is removing workspace data from database.
+ * The goal of this class is removing data from database.
  *
  * @author <a href="karpenko.sergiy at gmail.com">Karpenko Sergiy</a> 
  * @version $Id: DBCleaner.java 3769 2011-01-04 15:36:06Z areshetnyak $
@@ -63,11 +63,6 @@
    protected final List<String> commitScripts = new ArrayList<String>();
 
    /**
-    * DB clean helper.
-    */
-   protected final DBCleanHelper dbCleanHelper;
-
-   /**
     * Idicates if executing scripts should be done in autoCommit mode.                  
     */
    protected final boolean autoCommit;
@@ -89,37 +84,16 @@
     *          indicates if executing scripts should be done in autoCommit mode                  
     */
    public DBCleaner(Connection connection, List<String> cleanScripts, List<String> rollbackScripts,
-      List<String> commitScripts, DBCleanHelper dbCleanHelper, boolean autoCommit)
+      List<String> commitScripts, boolean autoCommit)
    {
       this.connection = connection;
       this.cleanScripts.addAll(cleanScripts);
       this.rollbackScripts.addAll(rollbackScripts);
       this.commitScripts.addAll(commitScripts);
-      this.dbCleanHelper = dbCleanHelper;
       this.autoCommit = autoCommit;
    }
 
    /**
-    * DBCleaner constructor.
-    * 
-    * @param connection 
-    *          connection to database where workspace tables is placed
-    * @param cleanScripts
-    *          scripts for cleaning database
-    * @param rollbackScripts
-    *          scripts for execution when something failed         
-    * @param commitScripts
-    *          scripts for removing temporary objects
-    * @param autoCommit
-    *          indicates if executing scripts should be done in autoCommit mode                  
-    */
-   public DBCleaner(Connection connection, List<String> cleanScripts, List<String> rollbackScripts,
-      List<String> commitScripts, boolean autoCommit)
-   {
-      this(connection, cleanScripts, rollbackScripts, commitScripts, null, autoCommit);
-   }
-
-   /**
     * Clean data from database. The method doesn't close connection or perform commit.
     * 
     * @throws SQLException
@@ -128,11 +102,6 @@
    public void executeCleanScripts() throws SQLException
    {
       executeScripts(cleanScripts);
-
-      if (dbCleanHelper != null)
-      {
-         dbCleanHelper.executeCleanScripts();
-      }
    }
 
    /** 

Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DummyDBCleaner.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DummyDBCleaner.java	2012-01-13 08:22:15 UTC (rev 5449)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DummyDBCleaner.java	2012-01-13 09:39:01 UTC (rev 5450)
@@ -35,7 +35,7 @@
     */
    public DummyDBCleaner()
    {
-      super(null, new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), null, false);
+      super(null, new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), false);
    }
 
    /**

Deleted: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/RecursiveDBCleanHelper.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/RecursiveDBCleanHelper.java	2012-01-13 08:22:15 UTC (rev 5449)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/RecursiveDBCleanHelper.java	2012-01-13 09:39:01 UTC (rev 5450)
@@ -1,148 +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.clean.rdbms;
-
-import org.exoplatform.commons.utils.SecurityHelper;
-import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.security.PrivilegedExceptionAction;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-/**
- * 
- * Created by The eXo Platform SAS.
- *
- * Date: 21.01.2011
- * 
- * @author <a href="mailto:anatoliy.bazko at exoplatform.com.ua">Anatoliy Bazko</a>
- * @version $Id: RecursiveDBCleanHelper.java.java 34360 2010-11-11 11:11:11Z tolusha $
- */
-public class RecursiveDBCleanHelper implements DBCleanHelper
-{
-
-   /**
-    * Logger.
-    */
-   protected final static Log LOG = ExoLogger.getLogger("exo.jcr.component.core.RecursiveDBCleanHelper");
-
-   /**
-    * Select items query.
-    */
-   private final String selectItems;
-
-   /**
-    * Remove items query.
-    */
-   private final String removeItems;
-
-   /**
-    * Connection to database.
-    */
-   protected final Connection connection;
-
-   /**
-    * DBCleanerHelper constructor.
-    */
-   public RecursiveDBCleanHelper(Connection connection, String selectItemds, String removeItems)
-   {
-      this.connection = connection;
-      this.selectItems = selectItemds;
-      this.removeItems = removeItems;
-   }
-
-   /**
-    * Removing rows from table. Some database do not support cascade delete, 
-    * or need special sittings. In such case will be used deleting like
-    * visitor does. First traverse to the bottom of the tree and then go up to the root
-    * and perform deleting children.
-    * 
-    * @throws SQLException 
-    *          SQL exception. 
-    */
-   public void executeCleanScripts() throws SQLException
-   {
-      recursiveClean(Constants.ROOT_PARENT_UUID);
-   }
-
-   private void recursiveClean(String parentID) throws SQLException
-   {
-      PreparedStatement selectStatement = null;
-      PreparedStatement removeStatement = null;
-      ResultSet result = null;
-
-      try
-      {
-         selectStatement = connection.prepareStatement(this.selectItems);
-         selectStatement.setString(1, parentID);
-
-         final PreparedStatement fSelectStatement = selectStatement;
-         result = (ResultSet)SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Object>()
-         {
-            public Object run() throws Exception
-            {
-               return fSelectStatement.executeQuery();
-            }
-         });
-
-         // recursive traversing to the bottom of the tree
-         if (result.next())
-         {
-            do
-            {
-               recursiveClean(result.getString(1));
-            }
-            while (result.next());
-
-            // go up to the root and remove all nodes
-            removeStatement = connection.prepareStatement(this.removeItems);
-            removeStatement.setString(1, parentID);
-
-            final PreparedStatement fRemoveStatement = removeStatement;
-            SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Object>()
-            {
-               public Object run() throws Exception
-               {
-                  fRemoveStatement.executeUpdate();
-                  return null;
-               }
-            });
-         }
-      }
-      finally
-      {
-         if (selectStatement != null)
-         {
-            selectStatement.close();
-         }
-
-         if (removeStatement != null)
-         {
-            removeStatement.close();
-         }
-
-         if (result != null)
-         {
-            result.close();
-         }
-      }
-   }
-}



More information about the exo-jcr-commits mailing list