Author: sergiykarpenko
Date: 2009-12-24 03:18:30 -0500 (Thu, 24 Dec 2009)
New Revision: 1158
Added:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLConnectionFactory.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLMultiDbJDBCConnection.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLSingleDbJDBCConnection.java
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCStorageConnection.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCWorkspaceDataContainer.java
Log:
EXOJCR-302: MysSQL connections added
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCStorageConnection.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCStorageConnection.java 2009-12-23
16:49:34 UTC (rev 1157)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCStorageConnection.java 2009-12-24
08:18:30 UTC (rev 1158)
@@ -720,13 +720,13 @@
references.add((PropertyData)itemData(null, refProps, I_CLASS_PROPERTY,
null));
}
- ResultSet resultSet = findReferenceProperties(getInternalId(nodeIdentifier));
- references = new ArrayList<PropertyData>(); //List<PropertyData>
- if (resultSet.next())
- {
- while (!resultSet.isAfterLast())
- references.add(loadPropertyRecord(resultSet, null));
- }
+ // ResultSet resultSet =
findReferenceProperties(getInternalId(nodeIdentifier));
+ // List<PropertyData> references = new
ArrayList<PropertyData>(); //
+ // if (resultSet.next())
+ // {
+ // while (!resultSet.isAfterLast())
+ // references.add(loadPropertyRecord(resultSet, null));
+ // }
return references;
}
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCWorkspaceDataContainer.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCWorkspaceDataContainer.java 2009-12-23
16:49:34 UTC (rev 1157)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCWorkspaceDataContainer.java 2009-12-24
08:18:30 UTC (rev 1158)
@@ -24,7 +24,6 @@
import org.exoplatform.services.jcr.impl.storage.WorkspaceDataContainerBase;
import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.GenericConnectionFactory;
-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.init.DBInitializer;
@@ -33,6 +32,7 @@
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.optimisation.db.HSQLDBConnectionFactory;
+import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.MySQLConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.update.StorageUpdateManager;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
Added:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLConnectionFactory.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLConnectionFactory.java
(rev 0)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLConnectionFactory.java 2009-12-24
08:18:30 UTC (rev 1158)
@@ -0,0 +1,130 @@
+/*
+ * 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.impl.storage.jdbc.db.GenericConnectionFactory;
+import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+
+import java.io.File;
+import java.sql.SQLException;
+
+import javax.jcr.RepositoryException;
+import javax.sql.DataSource;
+
+/**
+ * Created by The eXo Platform SAS
+ *
+ * 16.03.2007
+ *
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
+ * @version $Id: MySQLConnectionFactory.java 34801 2009-07-31 15:44:50Z dkatayev $
+ */
+public class MySQLConnectionFactory extends GenericConnectionFactory
+{
+
+ /**
+ * MySQLConnectionFactory constructor.
+ *
+ *@param dataSource
+ * - DataSource
+ * @param dbDriver
+ * - JDBC Driver
+ * @param dbUrl
+ * - JDBC URL
+ * @param dbUserName
+ * - database username
+ * @param dbPassword
+ * - database user password
+ * @param containerName
+ * - Container name (see configuration)
+ * @param multiDb
+ * - multidatabase state flag
+ * @param valueStorageProvider
+ * - external Value Storages provider
+ * @param maxBufferSize
+ * - Maximum buffer size (see configuration)
+ * @param swapDirectory
+ * - Swap directory (see configuration)
+ * @param swapCleaner
+ * - Swap cleaner (internal FileCleaner).
+ * @throws RepositoryException
+ * if error eccurs
+ */
+ public MySQLConnectionFactory(String dbDriver, String dbUrl, String dbUserName, String
dbPassword,
+ String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
+ File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ {
+
+ super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
+ swapDirectory, swapCleaner);
+ }
+
+ /**
+ * MySQLConnectionFactory constructor.
+ *
+ * @param dataSource
+ * - DataSource
+ * @param containerName
+ * - Container name (see configuration)
+ * @param multiDb
+ * - multidatabase state flag
+ * @param valueStorageProvider
+ * - external Value Storages provider
+ * @param maxBufferSize
+ * - Maximum buffer size (see configuration)
+ * @param swapDirectory
+ * - Swap directory (see configuration)
+ * @param swapCleaner
+ * - Swap cleaner (internal FileCleaner).
+ */
+ public MySQLConnectionFactory(DataSource dbDataSource, String containerName, boolean
multiDb,
+ ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ {
+
+ super(dbDataSource, containerName, multiDb, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public WorkspaceStorageConnection openConnection(boolean readOnly) throws
RepositoryException
+ {
+ try
+ {
+
+ if (multiDb)
+ {
+ return new MySQLMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ }
+
+ return new MySQLSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+}
Added:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLMultiDbJDBCConnection.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLMultiDbJDBCConnection.java
(rev 0)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLMultiDbJDBCConnection.java 2009-12-24
08:18:30 UTC (rev 1158)
@@ -0,0 +1,117 @@
+/*
+ * 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.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * Created by The eXo Platform SAS
+ *
+ * 20.03.2007
+ *
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
+ * @version $Id: MySQLMultiDbJDBCConnection.java 34801 2009-07-31 15:44:50Z dkatayev $
+ */
+public class MySQLMultiDbJDBCConnection extends MultiDbJDBCConnection
+{
+
+ /**
+ * MySQL 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 File (see configuration)
+ * @param swapCleaner
+ * Swap cleaner (internal FileCleaner).
+ * @throws SQLException
+ *
+ * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ */
+ public MySQLMultiDbJDBCConnection(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 int addNodeRecord(NodeData data) throws SQLException
+ {
+ // check if parent exists
+ if (data.getParentIdentifier() != null)
+ {
+ ResultSet item = findItemByIdentifier(data.getParentIdentifier());
+ try
+ {
+ if (!item.next())
+ throw new SQLException("Parent is not found. Behaviour of " +
JCR_FK_ITEM_PARENT);
+ }
+ finally
+ {
+ item.close();
+ }
+ }
+ return super.addNodeRecord(data);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addPropertyRecord(PropertyData data) throws SQLException
+ {
+ // check if parent exists
+ if (data.getParentIdentifier() != null)
+ {
+ ResultSet item = findItemByIdentifier(data.getParentIdentifier());
+ try
+ {
+ if (!item.next())
+ throw new SQLException("Parent is not found. Behaviour of " +
JCR_FK_ITEM_PARENT);
+ }
+ finally
+ {
+ item.close();
+ }
+ }
+ return super.addPropertyRecord(data);
+ }
+
+}
Added:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLSingleDbJDBCConnection.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLSingleDbJDBCConnection.java
(rev 0)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLSingleDbJDBCConnection.java 2009-12-24
08:18:30 UTC (rev 1158)
@@ -0,0 +1,117 @@
+/*
+ * 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.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * Created by The eXo Platform SAS
+ *
+ * 20.03.2007
+ *
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
+ * @version $Id: MySQLSingleDbJDBCConnection.java 34801 2009-07-31 15:44:50Z dkatayev $
+ */
+public class MySQLSingleDbJDBCConnection extends SingleDbJDBCConnection
+{
+
+ /**
+ * MySQL Singledatabase JDBC Connection constructor.
+ *
+ * @param dbConnection
+ * JDBC connection, shoudl be opened before
+ * @param readOnly
+ * boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerName
+ * Workspace Storage Container name (see configuration)
+ * @param valueStorageProvider
+ * External Value Storages provider
+ * @param maxBufferSize
+ * Maximum buffer size (see configuration)
+ * @param swapDirectory
+ * Swap directory File (see configuration)
+ * @param swapCleaner
+ * Swap cleaner (internal FileCleaner).
+ * @throws SQLException
+ *
+ * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ */
+ public MySQLSingleDbJDBCConnection(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 int addNodeRecord(NodeData data) throws SQLException
+ {
+ // check if parent exists
+ if (data.getParentIdentifier() != null)
+ {
+ ResultSet item =
findItemByIdentifier(getInternalId(data.getParentIdentifier()));
+ try
+ {
+ if (!item.next())
+ throw new SQLException("Parent is not found. Behaviour of " +
JCR_FK_ITEM_PARENT);
+ }
+ finally
+ {
+ item.close();
+ }
+ }
+ return super.addNodeRecord(data);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addPropertyRecord(PropertyData data) throws SQLException
+ {
+ // check if parent exists
+ if (data.getParentIdentifier() != null)
+ {
+ ResultSet item =
findItemByIdentifier(getInternalId(data.getParentIdentifier()));
+ try
+ {
+ if (!item.next())
+ throw new SQLException("Parent is not found. Behaviour of " +
JCR_FK_ITEM_PARENT);
+ }
+ finally
+ {
+ item.close();
+ }
+ }
+ return super.addPropertyRecord(data);
+ }
+
+}