Author: dkatayev
Date: 2009-08-28 02:54:41 -0400 (Fri, 28 Aug 2009)
New Revision: 25
Added:
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCConnectionTestBase.java
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
jcr/trunk/component/core/src/test/java/conf/standalone/test-configuration-sjdbc.xml
jcr/trunk/component/core/src/test/java/conf/standalone/test-configuration.xml
Log:
EXOJCR-2 Sources migration to JBoss SVN
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2009-08-28
06:34:31 UTC (rev 24)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2009-08-28
06:54:41 UTC (rev 25)
@@ -1,20 +1,18 @@
/*
- * Copyright (C) 2009 eXo Platform SAS.
+ * Copyright (C) 2003-2007 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 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 software is distributed in the hope that it will be useful,
+ * 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
- * Lesser General Public License for more details.
+ * 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 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.
+ * 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.storage.jdbc;
@@ -33,6 +31,7 @@
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.impl.storage.WorkspaceDataContainerBase;
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;
@@ -56,726 +55,723 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
* @version $Id:GenericWorkspaceDataContainer.java 13433 2007-03-15 16:07:23Z peterit $
*/
-public class JDBCWorkspaceDataContainer extends WorkspaceDataContainerBase implements
Startable
-{
+public class JDBCWorkspaceDataContainer extends WorkspaceDataContainerBase implements
Startable {
- protected static final Log LOG =
ExoLogger.getLogger("jcr.JDBCWorkspaceDataContainer");
+ protected static final Log LOG =
ExoLogger.getLogger("jcr.JDBCWorkspaceDataContainer");
- //configuration params
+ //configuration params
- public final static String SOURCE_NAME = "source-name";
+ public final static String SOURCE_NAME = "source-name";
- public final static String MULTIDB = "multi-db";
+ public final static String MULTIDB = "multi-db";
- public final static String SINGLEDB = "single-db";
+ public final static String SINGLEDB = "single-db";
- /**
- * Describe which type of RDBMS will be used (DB creation metadata etc.)
- */
- public final static String DB_DIALECT = "dialect";
+ /**
+ * Describe which type of RDBMS will be used (DB creation metadata etc.)
+ */
+ public final static String DB_DIALECT = "dialect";
- public final static String DB_DRIVER = "driverClassName";
+ public final static String DB_DRIVER = "driverClassName";
- public final static String DB_URL = "url";
+ public final static String DB_URL = "url";
- public final static String DB_USERNAME = "username";
+ public final static String DB_USERNAME = "username";
- public final static String DB_PASSWORD = "password";
+ public final static String DB_PASSWORD = "password";
- protected final String containerName;
+ protected final String containerName;
- protected final String dbSourceName;
+ protected final String dbSourceName;
- protected final boolean multiDb;
+ protected final boolean multiDb;
- protected final String dbDriver;
+ protected final String dbDriver;
- protected final String dbDialect;
+ protected final String dbDialect;
- protected final String dbUrl;
+ protected final String dbUrl;
- protected final String dbUserName;
+ protected final String dbUserName;
- protected final String dbPassword;
+ protected final String dbPassword;
- protected final ValueStoragePluginProvider valueStorageProvider;
+ protected final ValueStoragePluginProvider valueStorageProvider;
- protected String storageVersion;
+ protected String storageVersion;
- protected int maxBufferSize;
+ protected int maxBufferSize;
- protected File swapDirectory;
+ protected File swapDirectory;
- protected FileCleaner swapCleaner;
+ protected FileCleaner swapCleaner;
- protected GenericConnectionFactory connFactory;
+ protected GenericConnectionFactory connFactory;
- /**
- * Shared connection factory.
- *
- * Issued to share JDBC connection between system and regular workspace in case of
same database
- * used for storage.
- *
- */
- class SharedConnectionFactory extends GenericConnectionFactory
- {
+ /**
+ * Shared connection factory.
+ *
+ * Issued to share JDBC connection between system and regular workspace in case of same
database
+ * used for storage.
+ *
+ */
+ class SharedConnectionFactory extends GenericConnectionFactory {
- /**
- * JDBC connection.
- */
- final private Connection connection;
+ /**
+ * JDBC connection.
+ */
+ final private Connection connection;
- /**
- * SharedConnectionFactory constructor.
- *
- * @param connection
- * JDBC - connection
- * @param containerName
- * - container name
- * @param multiDb
- * - multidatabase status
- * @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).
- */
- SharedConnectionFactory(Connection connection, String containerName, boolean
multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
- {
+ /**
+ * SharedConnectionFactory constructor.
+ *
+ * @param connection
+ * JDBC - connection
+ * @param containerName
+ * - container name
+ * @param multiDb
+ * - multidatabase status
+ * @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).
+ */
+ SharedConnectionFactory(Connection connection,
+ String containerName,
+ boolean multiDb,
+ ValueStoragePluginProvider valueStorageProvider,
+ int maxBufferSize,
+ File swapDirectory,
+ FileCleaner swapCleaner) {
- super(null, null, null, null, null, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ super(null,
+ null,
+ null,
+ null,
+ null,
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
- this.connection = connection;
- }
+ this.connection = connection;
+ }
- /**
- * {@inheritDoc}
- */
- public Connection getJdbcConnection() throws RepositoryException
- {
- return connection;
- }
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Connection getJdbcConnection() throws RepositoryException {
+ return connection;
+ }
+ }
- /**
- * Constructor with value storage plugins.
- *
- * @param wsConfig
- * Workspace configuration
- * @param valueStrorageProvider
- * External Value Stprages provider
- * @throws RepositoryConfigurationException
- * if Repository configuration is wrong
- * @throws NamingException
- * if JNDI exception (on DataSource lookup)
- */
- public JDBCWorkspaceDataContainer(WorkspaceEntry wsConfig, RepositoryEntry repConfig,
- InitialContextInitializer contextInit, ValueStoragePluginProvider
valueStorageProvider)
- throws RepositoryConfigurationException, NamingException, RepositoryException,
IOException
- {
+ /**
+ * Constructor with value storage plugins.
+ *
+ * @param wsConfig
+ * Workspace configuration
+ * @param valueStrorageProvider
+ * External Value Stprages provider
+ * @throws RepositoryConfigurationException
+ * if Repository configuration is wrong
+ * @throws NamingException
+ * if JNDI exception (on DataSource lookup)
+ */
+ public JDBCWorkspaceDataContainer(WorkspaceEntry wsConfig,
+ RepositoryEntry repConfig,
+ InitialContextInitializer contextInit,
+ ValueStoragePluginProvider valueStorageProvider)
throws RepositoryConfigurationException,
+ NamingException,
+ RepositoryException,
+ IOException {
- checkIntegrity(wsConfig, repConfig);
+ checkIntegrity(wsConfig, repConfig);
- this.containerName = wsConfig.getName();
- this.multiDb =
Boolean.parseBoolean(wsConfig.getContainer().getParameterValue(MULTIDB));
- this.valueStorageProvider = valueStorageProvider;
+ this.containerName = wsConfig.getName();
+ this.multiDb =
Boolean.parseBoolean(wsConfig.getContainer().getParameterValue(MULTIDB));
+ this.valueStorageProvider = valueStorageProvider;
- // ------------- Database config ------------------
- String pDbDialect = null;
- try
- {
- pDbDialect =
detectDialect(wsConfig.getContainer().getParameterValue(DB_DIALECT));
- LOG.info("Using a dialect '" + pDbDialect + "'");
- }
- catch (RepositoryConfigurationException e)
- {
- LOG.info("Using a default dialect '" +
DBConstants.DB_DIALECT_GENERIC + "'");
- pDbDialect = DBConstants.DB_DIALECT_GENERIC;
- }
- this.dbDialect = pDbDialect;
+ // ------------- Database config ------------------
+ String pDbDialect = null;
+ try {
+ pDbDialect = detectDialect(wsConfig.getContainer().getParameterValue(DB_DIALECT));
+ LOG.info("Using a dialect '" + pDbDialect + "'");
+ } catch (RepositoryConfigurationException e) {
+ LOG.info("Using a default dialect '" + DBConstants.DB_DIALECT_GENERIC
+ "'");
+ pDbDialect = DBConstants.DB_DIALECT_GENERIC;
+ }
+ this.dbDialect = pDbDialect;
- String pDbDriver = null;
- String pDbUrl = null;
- String pDbUserName = null;
- String pDbPassword = null;
- try
- {
- pDbDriver = wsConfig.getContainer().getParameterValue(DB_DRIVER);
+ String pDbDriver = null;
+ String pDbUrl = null;
+ String pDbUserName = null;
+ String pDbPassword = null;
+ try {
+ pDbDriver = wsConfig.getContainer().getParameterValue(DB_DRIVER);
- // 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!
+ // username/passwd may not pesent
+ try {
+ pDbUserName = wsConfig.getContainer().getParameterValue(DB_USERNAME);
+ pDbPassword = wsConfig.getContainer().getParameterValue(DB_PASSWORD);
+ } catch (RepositoryConfigurationException e) {
+ pDbUserName = pDbPassword = null;
}
- catch (RepositoryConfigurationException e)
- {
- }
- if (pDbUrl != null)
- {
- this.dbDriver = pDbDriver;
- this.dbUrl = pDbUrl;
- this.dbUserName = pDbUserName;
- this.dbPassword = pDbPassword;
- this.dbSourceName = null;
- LOG.info("Connect to JCR database as user '" + this.dbUserName +
"'");
- }
- else
- {
- this.dbDriver = null;
- this.dbUrl = null;
- this.dbUserName = null;
- this.dbPassword = null;
+ pDbUrl = wsConfig.getContainer().getParameterValue(DB_URL); // last here!
+ } catch (RepositoryConfigurationException e) {
+ }
- String sn;
- try
- {
- sn = wsConfig.getContainer().getParameterValue(SOURCE_NAME);
- }
- catch (RepositoryConfigurationException e)
- {
- sn = wsConfig.getContainer().getParameterValue("sourceName"); //
TODO for backward comp,
- // remove in rel.2.0
- }
- this.dbSourceName = sn;
- }
+ if (pDbUrl != null) {
+ this.dbDriver = pDbDriver;
+ this.dbUrl = pDbUrl;
+ this.dbUserName = pDbUserName;
+ this.dbPassword = pDbPassword;
+ this.dbSourceName = null;
+ LOG.info("Connect to JCR database as user '" + this.dbUserName +
"'");
+ } else {
+ this.dbDriver = null;
+ this.dbUrl = null;
+ this.dbUserName = null;
+ this.dbPassword = null;
- // ------------- Values swap config ------------------
- try
- {
- this.maxBufferSize =
wsConfig.getContainer().getParameterInteger(MAXBUFFERSIZE_PROP);
+ String sn;
+ try {
+ sn = wsConfig.getContainer().getParameterValue(SOURCE_NAME);
+ } catch (RepositoryConfigurationException e) {
+ sn = wsConfig.getContainer().getParameterValue("sourceName"); // TODO
for backward comp,
+ // remove in rel.2.0
}
- catch (RepositoryConfigurationException e)
- {
- this.maxBufferSize = DEF_MAXBUFFERSIZE;
- }
+ this.dbSourceName = sn;
+ }
- try
- {
- String sdParam = wsConfig.getContainer().getParameterValue(SWAPDIR_PROP);
- this.swapDirectory = new File(sdParam);
- }
- catch (RepositoryConfigurationException e1)
- {
- this.swapDirectory = new File(DEF_SWAPDIR);
- }
- if (!swapDirectory.exists())
- swapDirectory.mkdirs();
+ // ------------- Values swap config ------------------
+ try {
+ this.maxBufferSize =
wsConfig.getContainer().getParameterInteger(MAXBUFFERSIZE_PROP);
+ } catch (RepositoryConfigurationException e) {
+ this.maxBufferSize = DEF_MAXBUFFERSIZE;
+ }
- this.swapCleaner = new FileCleaner(false);
+ try {
+ String sdParam = wsConfig.getContainer().getParameterValue(SWAPDIR_PROP);
+ this.swapDirectory = new File(sdParam);
+ } catch (RepositoryConfigurationException e1) {
+ this.swapDirectory = new File(DEF_SWAPDIR);
+ }
+ if (!swapDirectory.exists())
+ swapDirectory.mkdirs();
- initDatabase();
+ this.swapCleaner = new FileCleaner(false);
- String suParam = null;
- boolean enableStorageUpdate = false;
- try
- {
- suParam =
wsConfig.getContainer().getParameterValue("update-storage");
- enableStorageUpdate = Boolean.parseBoolean(suParam);
- }
- catch (RepositoryConfigurationException e)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("update-storage parameter is not set " + dbSourceName);
- }
+ initDatabase();
- this.storageVersion =
- StorageUpdateManager.checkVersion(dbSourceName,
this.connFactory.getJdbcConnection(), multiDb,
- enableStorageUpdate);
+ String suParam = null;
+ boolean enableStorageUpdate = false;
+ try {
+ suParam = wsConfig.getContainer().getParameterValue("update-storage");
+ enableStorageUpdate = Boolean.parseBoolean(suParam);
+ } catch (RepositoryConfigurationException e) {
+ if (LOG.isDebugEnabled())
+ LOG.debug("update-storage parameter is not set " + dbSourceName);
+ }
- LOG.info(getInfo());
- }
+ this.storageVersion = StorageUpdateManager.checkVersion(dbSourceName,
+
this.connFactory.getJdbcConnection(),
+ multiDb,
+ enableStorageUpdate);
- /**
- * Prepare sefault connection factory.
- *
- * @return GenericConnectionFactory
- * @throws NamingException
- * on JNDI error
- * @throws RepositoryException
- * on Storage error
- */
- protected GenericConnectionFactory defaultConnectionFactory() throws NamingException,
RepositoryException
- {
- // by default
- if (dbSourceName != null)
- {
- DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
- if (ds != null)
- return new GenericConnectionFactory(ds, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ LOG.info(getInfo());
+ }
- throw new RepositoryException("Datasource '" + dbSourceName +
"' is not bound in this context.");
- }
+ /**
+ * Prepare sefault connection factory.
+ *
+ * @return GenericConnectionFactory
+ * @throws NamingException
+ * on JNDI error
+ * @throws RepositoryException
+ * on Storage error
+ */
+ protected GenericConnectionFactory defaultConnectionFactory() throws NamingException,
+ RepositoryException {
+ // by default
+ if (dbSourceName != null) {
+ DataSource ds = (DataSource) new InitialContext().lookup(dbSourceName);
+ if (ds != null)
+ return new GenericConnectionFactory(ds,
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
- return new GenericConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
- }
+ throw new RepositoryException("Datasource '" + dbSourceName
+ + "' is not bound in this context.");
+ }
- /**
- * Prepare default DB initializer.
- *
- * @param sqlPath
- * - path to SQL script (database creation script)
- * @return DBInitializer instance
- * @throws NamingException
- * on JNDI error
- * @throws RepositoryException
- * on Storage error
- * @throws IOException
- * on I/O error
- */
- protected DBInitializer defaultDBInitializer(String sqlPath) throws NamingException,
RepositoryException,
- IOException
- {
- return new DBInitializer(containerName, this.connFactory.getJdbcConnection(),
sqlPath, multiDb);
- }
+ return new GenericConnectionFactory(dbDriver,
+ dbUrl,
+ dbUserName,
+ dbPassword,
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
+ }
- /**
- * Checks if DataSources used in right manner.
- *
- * @param wsConfig
- * Workspace configuration
- * @param repConfig
- * Repository configuration
- * @throws RepositoryConfigurationException
- * in case of configuration errors
- */
- protected void checkIntegrity(WorkspaceEntry wsConfig, RepositoryEntry repConfig)
- throws RepositoryConfigurationException
- {
- boolean isMulti;
- for (WorkspaceEntry wsEntry : repConfig.getWorkspaceEntries())
- {
- if (wsEntry.getName().equals(wsConfig.getName())
- ||
!wsEntry.getContainer().getType().equals(wsConfig.getContainer().getType())
- || !wsEntry.getContainer().getType().equals(this.getClass().getName()))
- continue;
+ /**
+ * Prepare default DB initializer.
+ *
+ * @param sqlPath
+ * - path to SQL script (database creation script)
+ * @return DBInitializer instance
+ * @throws NamingException
+ * on JNDI error
+ * @throws RepositoryException
+ * on Storage error
+ * @throws IOException
+ * on I/O error
+ */
+ protected DBInitializer defaultDBInitializer(String sqlPath) throws NamingException,
+ RepositoryException,
+ IOException {
+ return new DBInitializer(containerName, this.connFactory.getJdbcConnection(),
sqlPath, multiDb);
+ }
- // MULTIDB
- if (!wsEntry.getContainer().getParameterValue(MULTIDB).equals(
- wsConfig.getContainer().getParameterValue(MULTIDB)))
- {
- throw new RepositoryConfigurationException("All workspaces must be
" + MULTIDB + " or " + SINGLEDB
- + ". But " + wsEntry.getName() + "- multi-db=" +
wsEntry.getContainer().getParameterValue(MULTIDB)
- + " and " + wsConfig.getName() + "- multi-db=" +
wsConfig.getContainer().getParameterValue(MULTIDB));
- }
+ /**
+ * Checks if DataSources used in right manner.
+ *
+ * @param wsConfig
+ * Workspace configuration
+ * @param repConfig
+ * Repository configuration
+ * @throws RepositoryConfigurationException
+ * in case of configuration errors
+ */
+ protected void checkIntegrity(WorkspaceEntry wsConfig, RepositoryEntry repConfig)
throws RepositoryConfigurationException {
+ boolean isMulti;
+ for (WorkspaceEntry wsEntry : repConfig.getWorkspaceEntries()) {
+ if (wsEntry.getName().equals(wsConfig.getName())
+ || !wsEntry.getContainer().getType().equals(wsConfig.getContainer().getType())
+ || !wsEntry.getContainer().getType().equals(this.getClass().getName()))
+ continue;
- isMulti =
Boolean.parseBoolean(wsConfig.getContainer().getParameterValue(MULTIDB));
+ // MULTIDB
+ if (!wsEntry.getContainer()
+ .getParameterValue(MULTIDB)
+ .equals(wsConfig.getContainer().getParameterValue(MULTIDB))) {
+ throw new RepositoryConfigurationException("All workspaces must be " +
MULTIDB + " or "
+ + SINGLEDB + ". But " + wsEntry.getName() + "-
multi-db="
+ + wsEntry.getContainer().getParameterValue(MULTIDB) + " and " +
wsConfig.getName()
+ + "- multi-db=" +
wsConfig.getContainer().getParameterValue(MULTIDB));
+ }
- // source name
- String wsSourceName = null;
- String newWsSourceName = null;
- try
- {
- wsSourceName =
wsEntry.getContainer().getParameterValue("sourceName");
- newWsSourceName =
wsConfig.getContainer().getParameterValue("sourceName");
- }
- catch (RepositoryConfigurationException e)
- {
- }
+ isMulti =
Boolean.parseBoolean(wsConfig.getContainer().getParameterValue(MULTIDB));
- if (wsSourceName != null && newWsSourceName != null)
- {
- if (isMulti)
- {
- if (wsSourceName.equals(newWsSourceName))
- {
- throw new RepositoryConfigurationException("SourceName " +
wsSourceName + " alredy in use in "
- + wsEntry.getName() + ". SourceName must be different in "
+ MULTIDB
- + ". Check configuration for " + wsConfig.getName());
- }
- }
- else
- {
- if (!wsSourceName.equals(newWsSourceName))
- {
- throw new RepositoryConfigurationException("SourceName must be
equals in " + SINGLEDB + " "
- + "repository." + " Check " + wsEntry.getName()
+ " and " + wsConfig.getName());
- }
- }
- continue;
- }
+ // source name
+ String wsSourceName = null;
+ String newWsSourceName = null;
+ try {
+ wsSourceName = wsEntry.getContainer().getParameterValue("sourceName");
+ newWsSourceName =
wsConfig.getContainer().getParameterValue("sourceName");
+ } catch (RepositoryConfigurationException e) {
+ }
- // 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 (wsSourceName != null && newWsSourceName != null) {
+ if (isMulti) {
+ if (wsSourceName.equals(newWsSourceName)) {
+ throw new RepositoryConfigurationException("SourceName " +
wsSourceName
+ + " alredy in use in " + wsEntry.getName() + ". SourceName
must be different in "
+ + MULTIDB + ". Check configuration for " +
wsConfig.getName());
+ }
+ } else {
+ if (!wsSourceName.equals(newWsSourceName)) {
+ throw new RepositoryConfigurationException("SourceName must be equals in
" + SINGLEDB
+ + " " + "repository." + " Check " +
wsEntry.getName() + " and "
+ + wsConfig.getName());
+ }
+ }
+ continue;
+ }
- if (wsUri != null && newWsUri != null)
- {
- if (isMulti)
- {
- if (wsUri.equals(newWsUri))
- {
- throw new RepositoryConfigurationException("db-url " + wsUri
+ " alredy in use in "
- + wsEntry.getName() + ". db-url must be different in " +
MULTIDB + ". Check configuration for "
- + wsConfig.getName());
-
- }
- }
- else
- {
- if (!wsUri.equals(newWsUri))
- {
- throw new RepositoryConfigurationException("db-url must be equals
in " + SINGLEDB + " "
- + "repository." + " Check " + wsEntry.getName()
+ " and " + wsConfig.getName());
- }
- }
- }
+ // db-url
+ String wsUri = null;
+ String newWsUri = null;
+ try {
+ wsUri = wsEntry.getContainer().getParameterValue("db-url");
+ newWsUri = wsConfig.getContainer().getParameterValue("db-url");
+ } catch (RepositoryConfigurationException e) {
}
- }
- /**
- * Init storage database.
- *
- * @throws NamingException
- * on JNDI error
- * @throws RepositoryException
- * on storage error
- * @throws IOException
- * on I/O error
- */
- protected void initDatabase() throws NamingException, RepositoryException,
IOException
- {
+ if (wsUri != null && newWsUri != null) {
+ if (isMulti) {
+ if (wsUri.equals(newWsUri)) {
+ throw new RepositoryConfigurationException("db-url " + wsUri +
" alredy in use in "
+ + wsEntry.getName() + ". db-url must be different in " +
MULTIDB
+ + ". Check configuration for " + wsConfig.getName());
- DBInitializer dbInitilizer = null;
- String sqlPath = null;
- if (dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
- {
- LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is
experimental!");
- // sample of connection factory customization
- if (dbSourceName != null)
- this.connFactory = defaultConnectionFactory();
- else
- this.connFactory =
- new OracleConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
-
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.ora.sql";
-
- // a particular db initializer may be configured here too
- dbInitilizer = new OracleDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
+ }
+ } else {
+ if (!wsUri.equals(newWsUri)) {
+ throw new RepositoryConfigurationException("db-url must be equals in
" + SINGLEDB + " "
+ + "repository." + " Check " + wsEntry.getName() +
" and " + wsConfig.getName());
+ }
+ }
}
- else if (dbDialect == DBConstants.DB_DIALECT_ORACLE)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.ora.sql";
- dbInitilizer = new OracleDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_PGSQL)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.pgsql.sql";
- dbInitilizer = new PgSQLDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_MYSQL)
- {
- // [PN] 28.06.07
- if (dbSourceName != null)
- {
- DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
- if (ds != null)
- this.connFactory =
- new MySQLConnectionFactory(ds, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
- else
- throw new RepositoryException("Datasource '" + dbSourceName
+ "' is not bound in this context.");
- }
- else
- this.connFactory =
- new MySQLConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ }
+ }
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.mysql.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_MYSQL_UTF8)
- {
- // [PN] 13.07.08
- if (dbSourceName != null)
- {
- DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
- if (ds != null)
- this.connFactory =
- new MySQLConnectionFactory(ds, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
- else
- throw new RepositoryException("Datasource '" + dbSourceName
+ "' is not bound in this context.");
- }
- else
- this.connFactory =
- new MySQLConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ /**
+ * Init storage database.
+ *
+ * @throws NamingException
+ * on JNDI error
+ * @throws RepositoryException
+ * on storage error
+ * @throws IOException
+ * on I/O error
+ */
+ protected void initDatabase() throws NamingException, RepositoryException, IOException
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.mysql-utf8.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_MSSQL)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.mssql.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_DERBY)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.derby.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_DB2)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.db2.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_DB2V8)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.db2v8.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_SYBASE)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.sybase.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_INGRES)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.ingres.sql";
- // using Postgres initializer
- dbInitilizer =
- new IngresSQLDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
- }
+ DBInitializer dbInitilizer = null;
+ String sqlPath = null;
+ if (dbDialect == DBConstants.DB_DIALECT_ORACLEOCI) {
+ LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is
experimental!");
+ // sample of connection factory customization
+ if (dbSourceName != null)
+ this.connFactory = defaultConnectionFactory();
else
- {
- // generic, DB_HSQLDB
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
+ this.connFactory = new OracleConnectionFactory(dbDriver,
+ dbUrl,
+ dbUserName,
+ dbPassword,
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
- // database type
- try
- {
- dbInitilizer.init();
- }
- catch (DBInitializerException e)
- {
- LOG.error("Error of init db " + e, e);
- }
- }
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.ora.sql";
- /**
- * Return ConnectionFactory.
- *
- * @return WorkspaceStorageConnectionFactory connection
- */
- protected GenericConnectionFactory getConnectionFactory()
- {
- return connFactory;
- }
+ // a particular db initializer may be configured here too
+ dbInitilizer = new OracleDBInitializer(containerName,
+ this.connFactory.getJdbcConnection(),
+ sqlPath,
+ multiDb);
+ } else if (dbDialect == DBConstants.DB_DIALECT_ORACLE) {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.ora.sql";
+ dbInitilizer = new OracleDBInitializer(containerName,
+ this.connFactory.getJdbcConnection(),
+ sqlPath,
+ multiDb);
+ } else if (dbDialect == DBConstants.DB_DIALECT_PGSQL) {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.pgsql.sql";
+ dbInitilizer = new PgSQLDBInitializer(containerName,
+ this.connFactory.getJdbcConnection(),
+ sqlPath,
+ multiDb);
+ } else if (dbDialect == DBConstants.DB_DIALECT_MYSQL) {
+ // [PN] 28.06.07
+ if (dbSourceName != null) {
+ DataSource ds = (DataSource) new InitialContext().lookup(dbSourceName);
+ if (ds != null)
+ this.connFactory = new MySQLConnectionFactory(ds,
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
+ else
+ throw new RepositoryException("Datasource '" + dbSourceName
+ + "' is not bound in this context.");
+ } else
+ this.connFactory = new MySQLConnectionFactory(dbDriver,
+ dbUrl,
+ dbUserName,
+ dbPassword,
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
- protected String detectDialect(String confParam)
- {
- for (String dbType : DBConstants.DB_DIALECTS)
- {
- if (dbType.equalsIgnoreCase(confParam))
- return dbType;
- }
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.mysql.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ } else if (dbDialect == DBConstants.DB_DIALECT_MYSQL_UTF8) {
+ // [PN] 13.07.08
+ if (dbSourceName != null) {
+ DataSource ds = (DataSource) new InitialContext().lookup(dbSourceName);
+ if (ds != null)
+ this.connFactory = new MySQLConnectionFactory(ds,
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
+ else
+ throw new RepositoryException("Datasource '" + dbSourceName
+ + "' is not bound in this context.");
+ } else
+ this.connFactory = new MySQLConnectionFactory(dbDriver,
+ dbUrl,
+ dbUserName,
+ dbPassword,
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
- return DBConstants.DB_DIALECT_GENERIC; // by default
- }
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.mysql-utf8.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ } else if (dbDialect == DBConstants.DB_DIALECT_MSSQL) {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.mssql.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ } else if (dbDialect == DBConstants.DB_DIALECT_DERBY) {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.derby.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ } else if (dbDialect == DBConstants.DB_DIALECT_DB2) {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.db2.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ } else if (dbDialect == DBConstants.DB_DIALECT_DB2V8) {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.db2v8.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ } else if (dbDialect == DBConstants.DB_DIALECT_SYBASE) {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.sybase.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ } else if (dbDialect == DBConstants.DB_DIALECT_INGRES) {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.ingres.sql";
+ // using Postgres initializer
+ dbInitilizer = new IngresSQLDBInitializer(containerName,
+ this.connFactory.getJdbcConnection(),
+ sqlPath,
+ multiDb);
+ } else if (dbDialect == DBConstants.DB_DIALECT_HSQLDB) {
+ if (dbSourceName != null) {
+ DataSource ds = (DataSource) new InitialContext()
+ .lookup(dbSourceName);
+ if (ds != null)
+ this.connFactory = new HSQLDBConnectionFactory(ds,
+ containerName, multiDb, valueStorageProvider,
+ maxBufferSize, swapDirectory, swapCleaner);
+ else
+ throw new RepositoryException("Datasource '" + dbSourceName
+ + "' is not bound in this context.");
+ } else
+ this.connFactory = new HSQLDBConnectionFactory(dbDriver, dbUrl,
+ dbUserName, dbPassword, containerName, multiDb,
+ valueStorageProvider, maxBufferSize, swapDirectory,
+ swapCleaner);
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") +
"jdbc.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ } else {
+ // generic, DB_HSQLDB
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ }
- /**
- * {@inheritDoc}
- */
- public WorkspaceStorageConnection openConnection() throws RepositoryException
- {
+ // database type
+ try {
+ dbInitilizer.init();
+ } catch (DBInitializerException e) {
+ LOG.error("Error of init db " + e, e);
+ }
+ }
- return connFactory.openConnection();
- }
+ /**
+ * Return ConnectionFactory.
+ *
+ * @return WorkspaceStorageConnectionFactory connection
+ */
+ protected GenericConnectionFactory getConnectionFactory() {
+ return connFactory;
+ }
- /**
- * {@inheritDoc}
- */
- public WorkspaceStorageConnection openConnection(boolean readOnly) throws
RepositoryException
- {
+ protected String detectDialect(String confParam) {
+ for (String dbType : DBConstants.DB_DIALECTS) {
+ if (dbType.equalsIgnoreCase(confParam))
+ return dbType;
+ }
- return connFactory.openConnection(readOnly);
- }
+ return DBConstants.DB_DIALECT_GENERIC; // by default
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public WorkspaceStorageConnection openConnection()
+ throws RepositoryException {
- /**
- * {@inheritDoc}
- */
- public WorkspaceStorageConnection reuseConnection(WorkspaceStorageConnection original)
throws RepositoryException
- {
+ return connFactory.openConnection();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public WorkspaceStorageConnection openConnection(boolean readOnly) throws
RepositoryException {
- if (original instanceof JDBCStorageConnection)
- {
- WorkspaceStorageConnectionFactory cFactory =
- new
SharedConnectionFactory(((JDBCStorageConnection)original).getJdbcConnection(),
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return connFactory.openConnection(readOnly);
+ }
- return cFactory.openConnection();
- }
- else
- {
- return openConnection();
- }
- }
+ /**
+ * {@inheritDoc}
+ */
+ public WorkspaceStorageConnection reuseConnection(WorkspaceStorageConnection original)
throws RepositoryException {
- /**
- * {@inheritDoc}
- */
- public String getName()
- {
- return containerName;
- }
+ if (original instanceof JDBCStorageConnection) {
+ WorkspaceStorageConnectionFactory cFactory = new
SharedConnectionFactory(((JDBCStorageConnection) original).getJdbcConnection(),
+
containerName,
+ multiDb,
+
valueStorageProvider,
+
maxBufferSize,
+
swapDirectory,
+
swapCleaner);
- /**
- * {@inheritDoc}
- */
- public String getInfo()
- {
- String str =
- "JDBC based JCR Workspace Data container \n" + "container name:
" + containerName + " \n"
- + "data source JNDI name: " + dbSourceName + "\n" +
"is multi database: " + multiDb + "\n"
- + "storage version: " + storageVersion + "\n" +
"value storage provider: " + valueStorageProvider + "\n"
- + "max buffer size (bytes): " + maxBufferSize + "\n" +
"swap directory path: "
- + swapDirectory.getAbsolutePath();
- return str;
- }
+ return cFactory.openConnection();
+ } else {
+ return openConnection();
+ }
+ }
- /**
- * {@inheritDoc}
- */
- public String getStorageVersion()
- {
- return storageVersion;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public String getName() {
+ return containerName;
+ }
- /**
- * {@inheritDoc}
- */
- public void start()
- {
- this.swapCleaner.start();
- }
+ /**
+ * {@inheritDoc}
+ */
+ public String getInfo() {
+ String str = "JDBC based JCR Workspace Data container \n" + "container
name: " + containerName
+ + " \n" + "data source JNDI name: " + dbSourceName +
"\n" + "is multi database: " + multiDb
+ + "\n" + "storage version: " + storageVersion +
"\n" + "value storage provider: "
+ + valueStorageProvider + "\n" + "max buffer size (bytes): " +
maxBufferSize + "\n"
+ + "swap directory path: " + swapDirectory.getAbsolutePath();
+ return str;
+ }
- /**
- * {@inheritDoc}
- */
- public void stop()
- {
- this.swapCleaner.halt();
- this.swapCleaner.interrupt();
+ /**
+ * {@inheritDoc}
+ */
+ public String getStorageVersion() {
+ return storageVersion;
+ }
- // TODO HSQLDB Stop (debug)
- // if (dbDialect.equals(DB_DIALECT_GENERIC) ||
- // dbDialect.equals(DB_DIALECT_HSQLDB)) {
- // // shutdown in-process HSQLDB database
- // System.out.println("Shutdown in-process HSQLDB database...");
- // try {
- // JDBCStorageConnection conn = (JDBCStorageConnection) openConnection();
- // Connection jdbcConn = conn.getJdbcConnection();
- // String dbUrl = jdbcConn.getMetaData().getURL();
- // if (dbUrl.startsWith("jdbc:hsqldb:file") ||
- // dbUrl.startsWith("jdbc:hsqldb:mem")) {
- // // yeah, there is in-process hsqldb, shutdown it now
- // jdbcConn.createStatement().execute("SHUTDOWN");
- // System.out.println("Shutdown in-process HSQLDB database... done.");
- // }
- // } catch (Throwable e) {
- // log.error("JDBC Data container stop error " + e);
- // e.printStackTrace();
- // }
- // }
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void start() {
+ this.swapCleaner.start();
+ }
- /**
- * {@inheritDoc}
- */
- public boolean isSame(WorkspaceDataContainer another)
- {
- if (another == this)
- return true;
+ /**
+ * {@inheritDoc}
+ */
+ public void stop() {
+ this.swapCleaner.halt();
+ this.swapCleaner.interrupt();
- if (another instanceof JDBCWorkspaceDataContainer)
- {
- JDBCWorkspaceDataContainer anotherJdbc = (JDBCWorkspaceDataContainer)another;
+ // TODO HSQLDB Stop (debug)
+ // if (dbDialect.equals(DB_DIALECT_GENERIC) ||
+ // dbDialect.equals(DB_DIALECT_HSQLDB)) {
+ // // shutdown in-process HSQLDB database
+ // System.out.println("Shutdown in-process HSQLDB database...");
+ // try {
+ // JDBCStorageConnection conn = (JDBCStorageConnection) openConnection();
+ // Connection jdbcConn = conn.getJdbcConnection();
+ // String dbUrl = jdbcConn.getMetaData().getURL();
+ // if (dbUrl.startsWith("jdbc:hsqldb:file") ||
+ // dbUrl.startsWith("jdbc:hsqldb:mem")) {
+ // // yeah, there is in-process hsqldb, shutdown it now
+ // jdbcConn.createStatement().execute("SHUTDOWN");
+ // System.out.println("Shutdown in-process HSQLDB database... done.");
+ // }
+ // } catch (Throwable e) {
+ // log.error("JDBC Data container stop error " + e);
+ // e.printStackTrace();
+ // }
+ // }
+ }
- if (getDbSourceName() != null)
- // by jndi ds name
- return getDbSourceName().equals(anotherJdbc.getDbSourceName());
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isSame(WorkspaceDataContainer another) {
+ if (another == this)
+ return true;
- // by db connection params
- return getDbDriver().equals(anotherJdbc.getDbDriver()) &&
getDbUrl().equals(anotherJdbc.getDbUrl())
- && getDbUserName().equals(anotherJdbc.getDbUserName());
- }
+ if (another instanceof JDBCWorkspaceDataContainer) {
+ JDBCWorkspaceDataContainer anotherJdbc = (JDBCWorkspaceDataContainer) another;
- return false;
- }
+ if (getDbSourceName() != null)
+ // by jndi ds name
+ return getDbSourceName().equals(anotherJdbc.getDbSourceName());
- /**
- * Used in <code>equals()</code>.
- *
- * @return DataSource name
- */
- protected String getDbSourceName()
- {
- return dbSourceName;
- }
+ // by db connection params
+ return getDbDriver().equals(anotherJdbc.getDbDriver()) &&
getDbUrl().equals(anotherJdbc.getDbUrl())
+ && getDbUserName().equals(anotherJdbc.getDbUserName());
+ }
- /**
- * Used in <code>equals()</code>.
- *
- * @return JDBC driver
- */
- protected String getDbDriver()
- {
- return dbDriver;
- }
+ return false;
+ }
- /**
- * Used in <code>equals()</code>.
- *
- * @return Database URL
- */
- protected String getDbUrl()
- {
- return dbUrl;
- }
+ /**
+ * Used in <code>equals()</code>.
+ *
+ * @return DataSource name
+ */
+ protected String getDbSourceName() {
+ return dbSourceName;
+ }
- /**
- * Used in <code>equals()</code>.
- *
- * @return Database username
- */
- protected String getDbUserName()
- {
- return dbUserName;
- }
+ /**
+ * Used in <code>equals()</code>.
+ *
+ * @return JDBC driver
+ */
+ protected String getDbDriver() {
+ return dbDriver;
+ }
+
+ /**
+ * Used in <code>equals()</code>.
+ *
+ * @return Database URL
+ */
+ protected String getDbUrl() {
+ return dbUrl;
+ }
+
+ /**
+ * Used in <code>equals()</code>.
+ *
+ * @return Database username
+ */
+ protected String getDbUserName() {
+ return dbUserName;
+ }
}
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java 2009-08-28
06:34:31 UTC (rev 24)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java 2009-08-28
06:54:41 UTC (rev 25)
@@ -1,20 +1,18 @@
/*
- * Copyright (C) 2009 eXo Platform SAS.
+ * Copyright (C) 2003-2007 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 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 software is distributed in the hope that it will be useful,
+ * 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
- * Lesser General Public License for more details.
+ * 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 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.
+ * 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.storage.jdbc.db;
@@ -42,521 +40,494 @@
*
* Created by The eXo Platform SAS. </br>
*
- * Concrete JDBC based data container that uses "table-set per Workspace
policy" i.e each JCR
- * Workspace storage is placed in dedicated DB.
- *
- * @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady
Azarenkov</a>
- * @version $Id: MultiDbJDBCConnection.java 34801 2009-07-31 15:44:50Z dkatayev $
+ * @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
-{
+public class MultiDbJDBCConnection extends JDBCStorageConnection {
- protected PreparedStatement findItemById;
+ protected PreparedStatement findItemById;
- protected PreparedStatement findItemByPath;
+ protected PreparedStatement findItemByPath;
- protected PreparedStatement findItemByName;
+ protected PreparedStatement findItemByName;
- protected PreparedStatement findChildPropertyByPath;
+ protected PreparedStatement findChildPropertyByPath;
- protected PreparedStatement findPropertyByName;
+ protected PreparedStatement findPropertyByName;
- protected PreparedStatement findDescendantNodes;
+ protected PreparedStatement findDescendantNodes;
- protected PreparedStatement findDescendantProperties;
+ protected PreparedStatement findDescendantProperties;
- protected PreparedStatement findReferences;
+ protected PreparedStatement findReferences;
- protected PreparedStatement findValuesByPropertyId;
+ protected PreparedStatement findValuesByPropertyId;
- protected PreparedStatement findValuesDataByPropertyId;
+ protected PreparedStatement findValuesDataByPropertyId;
+
+ protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
+
+ @Deprecated
+ protected PreparedStatement findValueByPropertyIdOrderNumber;
- protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
+ protected PreparedStatement findNodesByParentId;
- @Deprecated
- protected PreparedStatement findValueByPropertyIdOrderNumber;
+ protected PreparedStatement findPropertiesByParentId;
- protected PreparedStatement findNodesByParentId;
+ protected PreparedStatement insertNode;
- protected PreparedStatement findPropertiesByParentId;
+ protected PreparedStatement insertProperty;
- protected PreparedStatement insertNode;
+ protected PreparedStatement insertReference;
- protected PreparedStatement insertProperty;
+ protected PreparedStatement insertValue;
- protected PreparedStatement insertReference;
+ protected PreparedStatement updateItem;
- protected PreparedStatement insertValue;
+ protected PreparedStatement updateItemPath;
- protected PreparedStatement updateItem;
+ protected PreparedStatement updateNode;
- protected PreparedStatement updateItemPath;
+ protected PreparedStatement updateProperty;
- protected PreparedStatement updateNode;
+ protected PreparedStatement updateValue;
- protected PreparedStatement updateProperty;
+ protected PreparedStatement deleteItem;
- protected PreparedStatement updateValue;
+ protected PreparedStatement deleteNode;
- protected PreparedStatement deleteItem;
+ protected PreparedStatement deleteProperty;
- protected PreparedStatement deleteNode;
+ protected PreparedStatement deleteReference;
- protected PreparedStatement deleteProperty;
+ protected PreparedStatement deleteValue;
- protected PreparedStatement deleteReference;
+ protected PreparedStatement renameNode;
- protected PreparedStatement deleteValue;
+ /**
+ * 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 {
- protected PreparedStatement renameNode;
+ super(dbConnection,
+ readOnly,
+ containerName,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
+ }
- /**
- * 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
- {
+ /**
+ * {@inheritDoc}
+ */
+ protected String getIdentifier(final String internalId) {
+ return internalId;
+ }
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
- }
+ /**
+ * {@inheritDoc}
+ */
+ protected String getInternalId(final String identifier) {
+ return identifier;
+ }
- /**
- * {@inheritDoc}
- */
- protected String getIdentifier(final String internalId)
- {
- return internalId;
- }
+ /**
+ * {@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_NAME = "JCR_IDX_MITEM_PARENT_NAME";
+ 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";
- /**
- * {@inheritDoc}
- */
- protected String getInternalId(final String identifier)
- {
- return identifier;
- }
+ FIND_ITEM_BY_ID = "select * from JCR_MITEM where ID=?";
- /**
- * {@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_NAME = "JCR_IDX_MITEM_PARENT_NAME";
- 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_NAME = "select * from JCR_MITEM"
+ + " where PARENT_ID=? and NAME=? and I_INDEX=? order by I_CLASS, VERSION
DESC";
- FIND_ITEM_BY_ID = "select * from JCR_MITEM where ID=?";
+ 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_ITEM_BY_NAME =
- "select * from JCR_MITEM" + " where PARENT_ID=? and NAME=? and
I_INDEX=? order by I_CLASS, VERSION DESC";
+ 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_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_VALUES_BY_PROPERTYID = "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC
from JCR_MVALUE where PROPERTY_ID=? order by 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_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from
JCR_MVALUE where PROPERTY_ID=?";
- FIND_VALUES_BY_PROPERTYID =
- "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_MVALUE where
PROPERTY_ID=? order by ORDER_NUM";
+ FIND_VALUE_BY_PROPERTYID_OREDERNUMB = "select DATA from JCR_MVALUE where
PROPERTY_ID=? and ORDER_NUM=?";
- FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from
JCR_MVALUE where PROPERTY_ID=?";
+ FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=1
and PARENT_ID=?"
+ + " order by N_ORDER_NUM";
- FIND_VALUE_BY_PROPERTYID_OREDERNUMB = "select DATA from JCR_MVALUE where
PROPERTY_ID=? and ORDER_NUM=?";
+ FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where
I_CLASS=2 and PARENT_ID=?"
+ + " order by ID";
- FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where
I_CLASS=1 and PARENT_ID=?" + " order by N_ORDER_NUM";
+ 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 + ",?,?,?)";
- FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where
I_CLASS=2 and PARENT_ID=?" + " order by ID";
+ 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(?,?,?)";
- 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 + ",?,?,?)";
+ RENAME_NODE = "update JCR_MITEM set PARENT_ID=?, NAME =?, VERSION=?, I_INDEX =?,
N_ORDER_NUM =? where ID=?";
- 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(?,?,?)";
+ 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=?";
- RENAME_NODE = "update JCR_MITEM set PARENT_ID=?, NAME =?, VERSION=?, I_INDEX
=?, N_ORDER_NUM =? where ID=?";
+ 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=?";
+ }
- 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=?";
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addNodeRecord(NodeData data) throws SQLException {
+ if (insertNode == null)
+ insertNode = dbConnection.prepareStatement(INSERT_NODE);
+ else
+ insertNode.clearParameters();
- 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=?";
- }
+ 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 addNodeRecord(NodeData data) throws SQLException
- {
- if (insertNode == null)
- insertNode = dbConnection.prepareStatement(INSERT_NODE);
- else
- insertNode.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addPropertyRecord(PropertyData data) throws SQLException {
+ if (insertProperty == null)
+ insertProperty = dbConnection.prepareStatement(INSERT_PROPERTY);
+ else
+ insertProperty.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();
- }
+ 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());
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addPropertyRecord(PropertyData data) throws SQLException
- {
- if (insertProperty == null)
- insertProperty = dbConnection.prepareStatement(INSERT_PROPERTY);
- else
- insertProperty.clearParameters();
+ return insertProperty.executeUpdate();
+ }
- 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());
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addReference(PropertyData data) throws SQLException, IOException {
+ if (insertReference == null)
+ insertReference = dbConnection.prepareStatement(INSERT_REF);
+ else
+ insertReference.clearParameters();
- return insertProperty.executeUpdate();
- }
+ if (data.getQPath().getAsString().indexOf("versionableUuid") > 0)
+ LOG.info("add ref versionableUuid " + data.getQPath().getAsString());
- /**
- * {@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 = ValueDataConvertor.readString(vdata);
- if (data.getQPath().getAsString().indexOf("versionableUuid") > 0)
- LOG.info("add ref versionableUuid " + data.getQPath().getAsString());
+ insertReference.setString(1, refNodeIdentifier);
+ insertReference.setString(2, data.getIdentifier());
+ insertReference.setInt(3, i);
+ added += insertReference.executeUpdate();
+ }
- 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);
+ return added;
+ }
- insertReference.setString(1, refNodeIdentifier);
- insertReference.setString(2, data.getIdentifier());
- insertReference.setInt(3, i);
- added += insertReference.executeUpdate();
- }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int deleteReference(String propertyIdentifier) throws SQLException {
+ if (deleteReference == null)
+ deleteReference = dbConnection.prepareStatement(DELETE_REF);
+ else
+ deleteReference.clearParameters();
- return added;
- }
+ deleteReference.setString(1, propertyIdentifier);
+ return deleteReference.executeUpdate();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected int deleteReference(String propertyIdentifier) throws SQLException
- {
- if (deleteReference == null)
- deleteReference = dbConnection.prepareStatement(DELETE_REF);
- else
- deleteReference.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int deleteItemByIdentifier(String identifier) throws SQLException {
+ if (deleteItem == null)
+ deleteItem = dbConnection.prepareStatement(DELETE_ITEM);
+ else
+ deleteItem.clearParameters();
- deleteReference.setString(1, propertyIdentifier);
- return deleteReference.executeUpdate();
- }
+ deleteItem.setString(1, identifier);
+ return deleteItem.executeUpdate();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected int deleteItemByIdentifier(String identifier) throws SQLException
- {
- if (deleteItem == null)
- deleteItem = dbConnection.prepareStatement(DELETE_ITEM);
- else
- deleteItem.clearParameters();
+ /**
+ * {@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();
- deleteItem.setString(1, identifier);
- return deleteItem.executeUpdate();
- }
+ updateNode.setInt(1, version);
+ updateNode.setInt(2, index);
+ updateNode.setInt(3, orderNumb);
+ updateNode.setString(4, identifier);
+ return updateNode.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();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int updatePropertyByIdentifier(int version, int type, String identifier)
throws SQLException {
+ if (updateProperty == null)
+ updateProperty = dbConnection.prepareStatement(UPDATE_PROPERTY);
+ else
+ updateProperty.clearParameters();
- updateNode.setInt(1, version);
- updateNode.setInt(2, index);
- updateNode.setInt(3, orderNumb);
- updateNode.setString(4, identifier);
- return updateNode.executeUpdate();
- }
+ updateProperty.setInt(1, version);
+ updateProperty.setInt(2, type);
+ updateProperty.setString(3, identifier);
+ return updateProperty.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();
+ /**
+ * {@inheritDoc}
+ */
+ protected ResultSet findItemByName(String parentId, String name, int index) throws
SQLException {
+ if (findItemByName == null)
+ findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
+ else
+ findItemByName.clearParameters();
- updateProperty.setInt(1, version);
- updateProperty.setInt(2, type);
- updateProperty.setString(3, identifier);
- return updateProperty.executeUpdate();
- }
+ findItemByName.setString(1, parentId);
+ findItemByName.setString(2, name);
+ findItemByName.setInt(3, index);
+ return findItemByName.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- protected ResultSet findItemByName(String parentId, String name, int index) throws
SQLException
- {
- if (findItemByName == null)
- findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
- else
- findItemByName.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findPropertyByName(String parentId, String name) throws
SQLException {
+ if (findPropertyByName == null)
+ findPropertyByName = dbConnection.prepareStatement(FIND_PROPERTY_BY_NAME);
+ else
+ findPropertyByName.clearParameters();
- findItemByName.setString(1, parentId);
- findItemByName.setString(2, name);
- findItemByName.setInt(3, index);
- return findItemByName.executeQuery();
- }
+ findPropertyByName.setString(1, parentId);
+ findPropertyByName.setString(2, name);
+ return findPropertyByName.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();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findItemByIdentifier(String identifier) throws SQLException {
+ if (findItemById == null)
+ findItemById = dbConnection.prepareStatement(FIND_ITEM_BY_ID);
+ else
+ findItemById.clearParameters();
- findPropertyByName.setString(1, parentId);
- findPropertyByName.setString(2, name);
- return findPropertyByName.executeQuery();
- }
+ findItemById.setString(1, identifier);
+ return findItemById.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findItemByIdentifier(String identifier) throws SQLException
- {
- if (findItemById == null)
- findItemById = dbConnection.prepareStatement(FIND_ITEM_BY_ID);
- else
- findItemById.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findReferences(String nodeIdentifier) throws SQLException {
+ if (findReferences == null)
+ findReferences = dbConnection.prepareStatement(FIND_REFERENCES);
+ else
+ findReferences.clearParameters();
- findItemById.setString(1, identifier);
- return findItemById.executeQuery();
- }
+ findReferences.setString(1, nodeIdentifier);
+ return findReferences.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findReferences(String nodeIdentifier) throws SQLException
- {
- if (findReferences == null)
- findReferences = dbConnection.prepareStatement(FIND_REFERENCES);
- else
- findReferences.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildNodesByParentIdentifier(String parentIdentifier) throws
SQLException {
+ if (findNodesByParentId == null)
+ findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
+ else
+ findNodesByParentId.clearParameters();
- findReferences.setString(1, nodeIdentifier);
- return findReferences.executeQuery();
- }
+ findNodesByParentId.setString(1, parentIdentifier);
+ return findNodesByParentId.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildNodesByParentIdentifier(String parentIdentifier) throws
SQLException
- {
- if (findNodesByParentId == null)
- findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
- else
- findNodesByParentId.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildPropertiesByParentIdentifier(String parentIdentifier)
throws SQLException {
+ if (findPropertiesByParentId == null)
+ findPropertiesByParentId =
dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
+ else
+ findPropertiesByParentId.clearParameters();
- findNodesByParentId.setString(1, parentIdentifier);
- return findNodesByParentId.executeQuery();
- }
+ findPropertiesByParentId.setString(1, parentIdentifier);
+ return findPropertiesByParentId.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildPropertiesByParentIdentifier(String parentIdentifier)
throws SQLException
- {
- if (findPropertiesByParentId == null)
- findPropertiesByParentId =
dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
- else
- findPropertiesByParentId.clearParameters();
+ // -------- values processing ------------
- findPropertiesByParentId.setString(1, parentIdentifier);
- return findPropertiesByParentId.executeQuery();
- }
+ /**
+ * {@inheritDoc}
+ */
+ protected int addValueData(String cid,
+ int orderNumber,
+ InputStream stream,
+ int streamLength,
+ String storageDesc) throws SQLException {
- // -------- values processing ------------
+ if (insertValue == null)
+ insertValue = dbConnection.prepareStatement(INSERT_VALUE);
+ else
+ insertValue.clearParameters();
- /**
- * {@inheritDoc}
- */
- protected int addValueData(String cid, int orderNumber, InputStream stream, int
streamLength, String storageDesc)
- throws SQLException
- {
+ 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);
+ }
- if (insertValue == null)
- insertValue = dbConnection.prepareStatement(INSERT_VALUE);
- else
- insertValue.clearParameters();
+ insertValue.setInt(2, orderNumber);
+ insertValue.setString(3, cid);
+ return insertValue.executeUpdate();
+ }
- 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);
- }
+ /**
+ * {@inheritDoc}
+ */
+ protected int deleteValueData(String cid) throws SQLException {
+ if (deleteValue == null)
+ deleteValue = dbConnection.prepareStatement(DELETE_VALUE);
+ else
+ deleteValue.clearParameters();
- insertValue.setInt(2, orderNumber);
- insertValue.setString(3, cid);
- return insertValue.executeUpdate();
- }
+ deleteValue.setString(1, cid);
+ return deleteValue.executeUpdate();
+ }
- /**
- * {@inheritDoc}
- */
- protected int deleteValueData(String cid) throws SQLException
- {
- if (deleteValue == null)
- deleteValue = dbConnection.prepareStatement(DELETE_VALUE);
- else
- deleteValue.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ protected ResultSet findValuesByPropertyId(String cid) throws SQLException {
+ if (findValuesByPropertyId == null)
+ findValuesByPropertyId = dbConnection.prepareStatement(FIND_VALUES_BY_PROPERTYID);
+ else
+ findValuesByPropertyId.clearParameters();
- deleteValue.setString(1, cid);
- return deleteValue.executeUpdate();
- }
+ findValuesByPropertyId.setString(1, cid);
+ return findValuesByPropertyId.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- protected ResultSet findValuesByPropertyId(String cid) throws SQLException
- {
- if (findValuesByPropertyId == null)
- findValuesByPropertyId =
dbConnection.prepareStatement(FIND_VALUES_BY_PROPERTYID);
- else
- findValuesByPropertyId.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ protected ResultSet findValueByPropertyIdOrderNumber(String cid, int orderNumb) throws
SQLException {
+ if (findValueByPropertyIdOrderNumber == null)
+ findValueByPropertyIdOrderNumber =
dbConnection.prepareStatement(FIND_VALUE_BY_PROPERTYID_OREDERNUMB);
+ else
+ findValueByPropertyIdOrderNumber.clearParameters();
- findValuesByPropertyId.setString(1, cid);
- return findValuesByPropertyId.executeQuery();
- }
+ findValueByPropertyIdOrderNumber.setString(1, cid);
+ findValueByPropertyIdOrderNumber.setInt(2, orderNumb);
+ return findValueByPropertyIdOrderNumber.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- protected ResultSet findValueByPropertyIdOrderNumber(String cid, int orderNumb) throws
SQLException
- {
- if (findValueByPropertyIdOrderNumber == null)
- findValueByPropertyIdOrderNumber =
dbConnection.prepareStatement(FIND_VALUE_BY_PROPERTYID_OREDERNUMB);
- else
- findValueByPropertyIdOrderNumber.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int renameNode(NodeData data) throws SQLException {
+ if (renameNode == null)
+ renameNode = dbConnection.prepareStatement(RENAME_NODE);
+ else
+ renameNode.clearParameters();
- findValueByPropertyIdOrderNumber.setString(1, cid);
- findValueByPropertyIdOrderNumber.setInt(2, orderNumb);
- return findValueByPropertyIdOrderNumber.executeQuery();
- }
+ 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 int renameNode(NodeData data) throws SQLException
- {
- if (renameNode == null)
- renameNode = dbConnection.prepareStatement(RENAME_NODE);
- else
- renameNode.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findValuesStorageDescriptorsByPropertyId(String cid) throws
SQLException {
+ if (findValuesStorageDescriptorsByPropertyId == null)
+ findValuesStorageDescriptorsByPropertyId =
dbConnection.prepareStatement(FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID);
+ else
+ findValuesStorageDescriptorsByPropertyId.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();
- }
+ findValuesStorageDescriptorsByPropertyId.setString(1, cid);
+ return findValuesStorageDescriptorsByPropertyId.executeQuery();
+ }
}
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java 2009-08-28
06:34:31 UTC (rev 24)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java 2009-08-28
06:54:41 UTC (rev 25)
@@ -1,20 +1,18 @@
/*
- * Copyright (C) 2009 eXo Platform SAS.
+ * Copyright (C) 2003-2007 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 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 software is distributed in the hope that it will be useful,
+ * 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
- * Lesser General Public License for more details.
+ * 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 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.
+ * 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.storage.jdbc.db;
@@ -41,533 +39,505 @@
*
* 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 34801 2009-07-31 15:44:50Z dkatayev $
+ * @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
-{
+public class SingleDbJDBCConnection extends JDBCStorageConnection {
- protected PreparedStatement findItemById;
+ protected PreparedStatement findItemById;
- protected PreparedStatement findItemByPath;
+ protected PreparedStatement findItemByPath;
- protected PreparedStatement findItemByName;
+ protected PreparedStatement findItemByName;
- protected PreparedStatement findChildPropertyByPath;
+ protected PreparedStatement findChildPropertyByPath;
- protected PreparedStatement findPropertyByName;
+ protected PreparedStatement findPropertyByName;
- protected PreparedStatement findDescendantNodes;
+ protected PreparedStatement findDescendantNodes;
- protected PreparedStatement findDescendantProperties;
+ protected PreparedStatement findDescendantProperties;
- protected PreparedStatement findReferences;
+ protected PreparedStatement findReferences;
- protected PreparedStatement findValuesByPropertyId;
+ protected PreparedStatement findValuesByPropertyId;
+ protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
- protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
+ protected PreparedStatement findValuesDataByPropertyId;
- protected PreparedStatement findValuesDataByPropertyId;
+ protected PreparedStatement findValueByPropertyIdOrderNumber;
- protected PreparedStatement findValueByPropertyIdOrderNumber;
+ protected PreparedStatement findNodesByParentId;
- protected PreparedStatement findNodesByParentId;
+ protected PreparedStatement findPropertiesByParentId;
- protected PreparedStatement findPropertiesByParentId;
+ protected PreparedStatement insertItem;
- protected PreparedStatement insertItem;
+ protected PreparedStatement insertNode;
- protected PreparedStatement insertNode;
+ protected PreparedStatement insertProperty;
- protected PreparedStatement insertProperty;
+ protected PreparedStatement insertReference;
- protected PreparedStatement insertReference;
+ protected PreparedStatement insertValue;
- protected PreparedStatement insertValue;
+ protected PreparedStatement updateItem;
- protected PreparedStatement updateItem;
+ protected PreparedStatement updateItemPath;
- protected PreparedStatement updateItemPath;
+ protected PreparedStatement updateNode;
- protected PreparedStatement updateNode;
+ protected PreparedStatement updateProperty;
- protected PreparedStatement updateProperty;
+ protected PreparedStatement updateValue;
+
+ protected PreparedStatement deleteItem;
- protected PreparedStatement updateValue;
+ protected PreparedStatement deleteNode;
- protected PreparedStatement deleteItem;
+ protected PreparedStatement deleteProperty;
- protected PreparedStatement deleteNode;
+ protected PreparedStatement deleteReference;
- protected PreparedStatement deleteProperty;
+ protected PreparedStatement deleteValue;
- protected PreparedStatement deleteReference;
+ protected PreparedStatement renameNode;
- protected PreparedStatement deleteValue;
+ /**
+ * 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 {
- protected PreparedStatement renameNode;
+ super(dbConnection,
+ readOnly,
+ containerName,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
+ }
- /**
- * 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
- {
+ /**
+ * {@inheritDoc}
+ */
+ protected String getInternalId(final String identifier) {
+ return containerName + identifier;
+ }
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
- }
+ /**
+ * {@inheritDoc}
+ */
+ protected String getIdentifier(final String internalId) {
- /**
- * {@inheritDoc}
- */
- protected String getInternalId(final String identifier)
- {
- return containerName + identifier;
- }
+ if (internalId == null) // possible for root parent
+ return null;
- /**
- * {@inheritDoc}
- */
- protected String getIdentifier(final String internalId)
- {
+ return internalId.substring(containerName.length());
+ }
- if (internalId == null) // possible for root parent
- return null;
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void prepareQueries() throws SQLException {
- return internalId.substring(containerName.length());
- }
+ 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_NAME = "JCR_IDX_SITEM_PARENT_NAME";
+ 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";
- /**
- * {@inheritDoc}
- */
- @Override
- protected void prepareQueries() throws SQLException
- {
+ FIND_ITEM_BY_ID = "select * from JCR_SITEM where ID=?";
- 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_NAME = "JCR_IDX_SITEM_PARENT_NAME";
- 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_NAME = "select * from JCR_SITEM"
+ + " where CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=? order by
I_CLASS, VERSION DESC";
- FIND_ITEM_BY_ID = "select * from JCR_SITEM where ID=?";
+ 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_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_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_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_VALUES_BY_PROPERTYID = "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC
from JCR_SVALUE where PROPERTY_ID=? order by 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_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from
JCR_SVALUE where PROPERTY_ID=?";
- FIND_VALUES_BY_PROPERTYID =
- "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_SVALUE where
PROPERTY_ID=? order by ORDER_NUM";
+ FIND_VALUE_BY_PROPERTYID_OREDERNUMB = "select DATA from JCR_SVALUE where
PROPERTY_ID=? and ORDER_NUM=?";
- FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from
JCR_SVALUE where PROPERTY_ID=?";
+ FIND_NODES_BY_PARENTID = "select * from JCR_SITEM"
+ + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?" + "
order by N_ORDER_NUM";
- FIND_VALUE_BY_PROPERTYID_OREDERNUMB = "select DATA from JCR_SVALUE where
PROPERTY_ID=? and ORDER_NUM=?";
+ FIND_PROPERTIES_BY_PARENTID = "select * from JCR_SITEM"
+ + " where I_CLASS=2 and CONTAINER_NAME=? and PARENT_ID=?" + "
order by ID";
- FIND_NODES_BY_PARENTID =
- "select * from JCR_SITEM" + " where I_CLASS=1 and
CONTAINER_NAME=? and PARENT_ID=?" + " order by N_ORDER_NUM";
+ 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 + ",?,?,?)";
- FIND_PROPERTIES_BY_PARENTID =
- "select * from JCR_SITEM" + " where I_CLASS=2 and
CONTAINER_NAME=? and PARENT_ID=?" + " order by ID";
+ 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(?,?,?)";
- 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 + ",?,?,?)";
+ RENAME_NODE = "update JCR_SITEM set PARENT_ID=?, NAME=?, VERSION=?, I_INDEX=?,
N_ORDER_NUM=? where ID=?";
- 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(?,?,?)";
+ 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=?";
- RENAME_NODE = "update JCR_SITEM set PARENT_ID=?, NAME=?, VERSION=?, I_INDEX=?,
N_ORDER_NUM=? 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=?";
+ }
- 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=?";
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addNodeRecord(NodeData data) throws SQLException {
+ if (insertNode == null)
+ insertNode = dbConnection.prepareStatement(INSERT_NODE);
+ else
+ insertNode.clearParameters();
- 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=?";
- }
+ 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 addNodeRecord(NodeData data) throws SQLException
- {
- if (insertNode == null)
- insertNode = dbConnection.prepareStatement(INSERT_NODE);
- else
- insertNode.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addPropertyRecord(PropertyData data) throws SQLException {
+ if (insertProperty == null)
+ insertProperty = dbConnection.prepareStatement(INSERT_PROPERTY);
+ else
+ insertProperty.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();
- }
+ 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());
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addPropertyRecord(PropertyData data) throws SQLException
- {
- if (insertProperty == null)
- insertProperty = dbConnection.prepareStatement(INSERT_PROPERTY);
- else
- insertProperty.clearParameters();
+ return insertProperty.executeUpdate();
+ }
- 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());
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addReference(PropertyData data) throws SQLException, IOException {
+ if (insertReference == null)
+ insertReference = dbConnection.prepareStatement(INSERT_REF);
+ else
+ insertReference.clearParameters();
- return insertProperty.executeUpdate();
- }
+ 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());
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addReference(PropertyData data) throws SQLException, IOException
- {
- if (insertReference == null)
- insertReference = dbConnection.prepareStatement(INSERT_REF);
- else
- insertReference.clearParameters();
+ insertReference.setString(1, getInternalId(refNodeIdentifier));
+ insertReference.setString(2, getInternalId(data.getIdentifier()));
+ insertReference.setInt(3, i);
+ added += insertReference.executeUpdate();
+ }
+ return added;
+ }
- 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());
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int deleteReference(String propertyCid) throws SQLException {
+ if (deleteReference == null)
+ deleteReference = dbConnection.prepareStatement(DELETE_REF);
+ else
+ deleteReference.clearParameters();
- insertReference.setString(1, getInternalId(refNodeIdentifier));
- insertReference.setString(2, getInternalId(data.getIdentifier()));
- insertReference.setInt(3, i);
- added += insertReference.executeUpdate();
- }
- return added;
- }
+ deleteReference.setString(1, propertyCid);
+ return deleteReference.executeUpdate();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected int deleteReference(String propertyCid) throws SQLException
- {
- if (deleteReference == null)
- deleteReference = dbConnection.prepareStatement(DELETE_REF);
- else
- deleteReference.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int deleteItemByIdentifier(String cid) throws SQLException {
+ if (deleteItem == null)
+ deleteItem = dbConnection.prepareStatement(DELETE_ITEM);
+ else
+ deleteItem.clearParameters();
- deleteReference.setString(1, propertyCid);
- return deleteReference.executeUpdate();
- }
+ deleteItem.setString(1, cid);
+ return deleteItem.executeUpdate();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected int deleteItemByIdentifier(String cid) throws SQLException
- {
- if (deleteItem == null)
- deleteItem = dbConnection.prepareStatement(DELETE_ITEM);
- else
- deleteItem.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildNodesByParentIdentifier(String parentCid) throws
SQLException {
+ if (findNodesByParentId == null)
+ findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
+ else
+ findNodesByParentId.clearParameters();
- deleteItem.setString(1, cid);
- return deleteItem.executeUpdate();
- }
+ findNodesByParentId.setString(1, containerName);
+ findNodesByParentId.setString(2, parentCid);
+ return findNodesByParentId.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildNodesByParentIdentifier(String parentCid) throws
SQLException
- {
- if (findNodesByParentId == null)
- findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
- else
- findNodesByParentId.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildPropertiesByParentIdentifier(String parentCid) throws
SQLException {
+ if (findPropertiesByParentId == null)
+ findPropertiesByParentId =
dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
+ else
+ findPropertiesByParentId.clearParameters();
- findNodesByParentId.setString(1, containerName);
- findNodesByParentId.setString(2, parentCid);
- return findNodesByParentId.executeQuery();
- }
+ findPropertiesByParentId.setString(1, containerName);
+ findPropertiesByParentId.setString(2, parentCid);
+ return findPropertiesByParentId.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildPropertiesByParentIdentifier(String parentCid) throws
SQLException
- {
- if (findPropertiesByParentId == null)
- findPropertiesByParentId =
dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
- else
- findPropertiesByParentId.clearParameters();
+ /**
+ * {@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();
- findPropertiesByParentId.setString(1, containerName);
- findPropertiesByParentId.setString(2, parentCid);
- return findPropertiesByParentId.executeQuery();
- }
+ findItemByName.setString(1, containerName);
+ findItemByName.setString(2, parentId);
+ findItemByName.setString(3, name);
+ findItemByName.setInt(4, index);
+ return findItemByName.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();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findPropertyByName(String parentCid, String name) throws
SQLException {
+ if (findPropertyByName == null)
+ findPropertyByName = dbConnection.prepareStatement(FIND_PROPERTY_BY_NAME);
+ else
+ findPropertyByName.clearParameters();
- findItemByName.setString(1, containerName);
- findItemByName.setString(2, parentId);
- findItemByName.setString(3, name);
- findItemByName.setInt(4, index);
- return findItemByName.executeQuery();
- }
+ findPropertyByName.setString(1, containerName);
+ findPropertyByName.setString(2, parentCid);
+ findPropertyByName.setString(3, name);
+ return findPropertyByName.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();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findItemByIdentifier(String cid) throws SQLException {
+ if (findItemById == null)
+ findItemById = dbConnection.prepareStatement(FIND_ITEM_BY_ID);
+ else
+ findItemById.clearParameters();
- findPropertyByName.setString(1, containerName);
- findPropertyByName.setString(2, parentCid);
- findPropertyByName.setString(3, name);
- return findPropertyByName.executeQuery();
- }
+ findItemById.setString(1, cid);
+ return findItemById.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findItemByIdentifier(String cid) throws SQLException
- {
- if (findItemById == null)
- findItemById = dbConnection.prepareStatement(FIND_ITEM_BY_ID);
- else
- findItemById.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findReferences(String cid) throws SQLException {
+ if (findReferences == null)
+ findReferences = dbConnection.prepareStatement(FIND_REFERENCES);
+ else
+ findReferences.clearParameters();
- findItemById.setString(1, cid);
- return findItemById.executeQuery();
- }
+ findReferences.setString(1, cid);
+ findReferences.setString(2, containerName);
+ return findReferences.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findReferences(String cid) throws SQLException
- {
- if (findReferences == null)
- findReferences = dbConnection.prepareStatement(FIND_REFERENCES);
- else
- findReferences.clearParameters();
+ /**
+ * {@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();
- findReferences.setString(1, cid);
- findReferences.setString(2, containerName);
- return findReferences.executeQuery();
- }
+ updateNode.setInt(1, version);
+ updateNode.setInt(2, index);
+ updateNode.setInt(3, orderNumb);
+ updateNode.setString(4, cid);
+ return updateNode.executeUpdate();
+ }
- /**
- * {@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();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int updatePropertyByIdentifier(int version, int type, String cid) throws
SQLException {
+ if (updateProperty == null)
+ updateProperty = dbConnection.prepareStatement(UPDATE_PROPERTY);
+ else
+ updateProperty.clearParameters();
- updateNode.setInt(1, version);
- updateNode.setInt(2, index);
- updateNode.setInt(3, orderNumb);
- updateNode.setString(4, cid);
- return updateNode.executeUpdate();
- }
+ updateProperty.setInt(1, version);
+ updateProperty.setInt(2, type);
+ updateProperty.setString(3, cid);
+ return updateProperty.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();
+ // -------- values processing ------------
- updateProperty.setInt(1, version);
- updateProperty.setInt(2, type);
- updateProperty.setString(3, cid);
- return updateProperty.executeUpdate();
- }
+ /**
+ * {@inheritDoc}
+ */
+ protected int addValueData(String cid,
+ int orderNumber,
+ InputStream stream,
+ int streamLength,
+ String storageDesc) throws SQLException {
- // -------- values processing ------------
+ if (insertValue == null)
+ insertValue = dbConnection.prepareStatement(INSERT_VALUE);
+ else
+ insertValue.clearParameters();
- /**
- * {@inheritDoc}
- */
- protected int addValueData(String cid, int orderNumber, InputStream stream, int
streamLength, String storageDesc)
- throws SQLException
- {
+ 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);
+ }
- if (insertValue == null)
- insertValue = dbConnection.prepareStatement(INSERT_VALUE);
- else
- insertValue.clearParameters();
+ insertValue.setInt(2, orderNumber);
+ insertValue.setString(3, cid);
+ return insertValue.executeUpdate();
+ }
- 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);
- }
+ /**
+ * {@inheritDoc}
+ */
+ protected int deleteValueData(String cid) throws SQLException {
+ if (deleteValue == null)
+ deleteValue = dbConnection.prepareStatement(DELETE_VALUE);
+ else
+ deleteValue.clearParameters();
- insertValue.setInt(2, orderNumber);
- insertValue.setString(3, cid);
- return insertValue.executeUpdate();
- }
+ deleteValue.setString(1, cid);
+ return deleteValue.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected ResultSet findValuesByPropertyId(String cid) throws SQLException {
+ if (findValuesByPropertyId == null)
+ findValuesByPropertyId = dbConnection.prepareStatement(FIND_VALUES_BY_PROPERTYID);
+ else
+ findValuesByPropertyId.clearParameters();
- /**
- * {@inheritDoc}
- */
- protected int deleteValueData(String cid) throws SQLException
- {
- if (deleteValue == null)
- deleteValue = dbConnection.prepareStatement(DELETE_VALUE);
- else
- deleteValue.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();
- deleteValue.setString(1, cid);
- return deleteValue.executeUpdate();
- }
+ findValuesStorageDescriptorsByPropertyId.setString(1, cid);
+ return findValuesStorageDescriptorsByPropertyId.executeQuery();
+ }
+ /**
+ * {@inheritDoc}
+ */
+ @Deprecated
+ protected ResultSet findValueByPropertyIdOrderNumber(String cid, int orderNumb) throws
SQLException {
+ if (findValueByPropertyIdOrderNumber == null)
+ findValueByPropertyIdOrderNumber =
dbConnection.prepareStatement(FIND_VALUE_BY_PROPERTYID_OREDERNUMB);
+ else
+ findValueByPropertyIdOrderNumber.clearParameters();
- /**
- * {@inheritDoc}
- */
- protected ResultSet findValuesByPropertyId(String cid) throws SQLException
- {
- if (findValuesByPropertyId == null)
- findValuesByPropertyId =
dbConnection.prepareStatement(FIND_VALUES_BY_PROPERTYID);
- else
- findValuesByPropertyId.clearParameters();
+ findValueByPropertyIdOrderNumber.setString(1, cid);
+ findValueByPropertyIdOrderNumber.setInt(2, orderNumb);
+ return findValueByPropertyIdOrderNumber.executeQuery();
+ }
+
- findValuesByPropertyId.setString(1, cid);
- return findValuesByPropertyId.executeQuery();
- }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int renameNode(NodeData data) throws SQLException {
+ if (renameNode == null)
+ renameNode = dbConnection.prepareStatement(RENAME_NODE);
+ else
+ renameNode.clearParameters();
- /**
- * {@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}
- */
- @Deprecated
- 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();
- }
+ 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();
+ }
}
Modified:
jcr/trunk/component/core/src/test/java/conf/standalone/test-configuration-sjdbc.xml
===================================================================
---
jcr/trunk/component/core/src/test/java/conf/standalone/test-configuration-sjdbc.xml 2009-08-28
06:34:31 UTC (rev 24)
+++
jcr/trunk/component/core/src/test/java/conf/standalone/test-configuration-sjdbc.xml 2009-08-28
06:54:41 UTC (rev 25)
@@ -1,316 +1,355 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- 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.
-
--->
-<configuration
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd
http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+<configuration
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd
http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
- <component>
- <key>org.exoplatform.services.log.LogConfigurationInitializer</key>
- <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
- <init-params>
- <value-param>
- <name>logger</name>
-
<value>org.exoplatform.services.log.impl.BufferedLog4JLogger</value>
- </value-param>
- <value-param>
- <name>configurator</name>
-
<value>org.exoplatform.services.log.impl.Log4JConfigurator</value>
- </value-param>
- <properties-param>
- <name>properties</name>
- <description>Log4J properties</description>
- <property name="log4j.rootLogger" value="INFO, stdout,
file" />
+ <component>
+ <key>org.exoplatform.services.log.LogConfigurationInitializer</key>
+ <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
+ <init-params>
+ <value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedLog4JLogger</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.Log4JConfigurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>Log4J properties</description>
+ <property name="log4j.rootLogger" value="INFO, stdout,
file"/>
- <property name="log4j.appender.stdout"
value="org.apache.log4j.ConsoleAppender" />
- <property name="log4j.appender.stdout.threshold"
value="INFO" />
+ <property name="log4j.appender.stdout"
value="org.apache.log4j.ConsoleAppender"/>
+ <property name="log4j.appender.stdout.threshold"
value="INFO"/>
- <property name="log4j.appender.stdout.layout"
value="org.apache.log4j.PatternLayout" />
- <property name="log4j.appender.stdout.layout.ConversionPattern"
value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
+ <property name="log4j.appender.stdout.layout"
value="org.apache.log4j.PatternLayout"/>
+ <property name="log4j.appender.stdout.layout.ConversionPattern"
value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n"/>
- <property name="log4j.appender.file"
value="org.apache.log4j.FileAppender" />
- <property name="log4j.appender.file.File"
value="target/jcr.log" />
+ <property name="log4j.appender.file"
value="org.apache.log4j.FileAppender"/>
+ <property name="log4j.appender.file.File"
value="target/jcr.log"/>
- <property name="log4j.appender.file.layout"
value="org.apache.log4j.PatternLayout" />
- <property name="log4j.appender.file.layout.ConversionPattern"
value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
+ <property name="log4j.appender.file.layout"
value="org.apache.log4j.PatternLayout"/>
+ <property name="log4j.appender.file.layout.ConversionPattern"
value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n"/>
- <!-- property name="log4j.category.jcr.DBInitializer"
value="DEBUG"/ -->
-
- <!-- property name="log4j.category.jcr.SessionDataManager"
value="DEBUG" />
- <property name="log4j.category.jcr.JDBCStorageConnection"
value="DEBUG" />
- <property name="log4j.category.jcr.NodeImpl"
value="DEBUG" / -->
-
- <!-- property
name="log4j.category.jcr.WorkspaceStorageCacheImpl" value="DEBUG"/
-->
- <!-- property name="log4j.category.database.DBSchemaCreator"
value="DEBUG"/ -->
- <!-- property name="log4j.category.jcr.WorkspaceDataReplicator"
value="DEBUG"/ -->
+ <!-- property name="log4j.category.jcr.DBInitializer"
value="DEBUG"/ -->
- <!-- property
name="log4j.category.jcr.WorkspacePersistentDataManager"
value="DEBUG"/ -->
+ <!-- property name="log4j.category.jcr.SessionDataManager"
value="DEBUG"/>
+ <property name="log4j.category.jcr.JDBCStorageConnection"
value="DEBUG"/>
+ <property name="log4j.category.jcr.NodeImpl"
value="DEBUG"/ -->
- </properties-param>
+ <!-- property name="log4j.category.jcr.WorkspaceStorageCacheImpl"
value="DEBUG"/ -->
+ <!-- property name="log4j.category.database.DBSchemaCreator"
value="DEBUG"/ -->
+ <!-- property name="log4j.category.jcr.WorkspaceDataReplicator"
value="DEBUG"/ -->
- <!-- value-param>
- <name>logger</name>
-
<value>org.exoplatform.services.log.impl.BufferedSimpleLog</value>
- </value-param>
- <value-param>
- <name>configurator</name>
-
<value>org.exoplatform.services.log.impl.SimpleLogConfigurator</value>
- </value-param>
- <properties-param>
- <name>properties</name>
- <description>SimpleLog properties</description>
- <property name="org.apache.commons.logging.simplelog.defaultlog"
value="debug" />
- <property
name="org.apache.commons.logging.simplelog.showdatetime" value="true"
/>
- </properties-param -->
-
- <!-- value-param>
- <name>logger</name>
-
<value>org.exoplatform.services.log.impl.BufferedJdk14Logger</value>
- </value-param>
- <value-param>
- <name>configurator</name>
-
<value>org.exoplatform.services.log.impl.Jdk14Configurator</value>
- </value-param>
- <properties-param>
- <name>properties</name>
- <description>jdk1.4 Logger properties</description>
- <property name="handlers"
value="java.util.logging.ConsoleHandler" />
- <property name=".level" value="FINE" />
- <property name="java.util.logging.ConsoleHandler.level"
value="FINE" />
- </properties-param -->
+ <!-- property
name="log4j.category.jcr.WorkspacePersistentDataManager"
value="DEBUG"/ -->
- </init-params>
- </component>
- <component>
+ </properties-param>
+
+ <!-- value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedSimpleLog</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+
<value>org.exoplatform.services.log.impl.SimpleLogConfigurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>SimpleLog properties</description>
+ <property name="org.apache.commons.logging.simplelog.defaultlog"
value="debug"/>
+ <property name="org.apache.commons.logging.simplelog.showdatetime"
value="true"/>
+ </properties-param -->
+
+ <!-- value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedJdk14Logger</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.Jdk14Configurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>jdk1.4 Logger properties</description>
+ <property name="handlers"
value="java.util.logging.ConsoleHandler"/>
+ <property name=".level" value="FINE"/>
+ <property name="java.util.logging.ConsoleHandler.level"
value="FINE"/>
+ </properties-param -->
+
+ </init-params>
+ </component>
+ <component>
<key>org.exoplatform.services.jcr.RepositoryService</key>
<type>org.exoplatform.services.jcr.impl.RepositoryServiceImpl</type>
<component-plugins>
- <component-plugin>
+ <component-plugin>
<name>add.namespaces</name>
<set-method>addPlugin</set-method>
<type>org.exoplatform.services.jcr.impl.AddNamespacesPlugin</type>
<init-params>
- <properties-param>
- <name>namespaces</name>
- <property name="test"
value="http://www.apache.org/jackrabbit/test" />
- <property name="exojcrtest"
value="http://www.exoplatform.org/jcr/test/1.0" />
- <property name="rma"
value="http://www.rma.com/jcr/" />
- <property name="metadata"
value="http://www.exoplatform.com/jcr/metadata/1.1/" />
- </properties-param>
+ <properties-param>
+ <name>namespaces</name>
+ <property name="test"
value="http://www.apache.org/jackrabbit/test"/>
+ <property name="exojcrtest"
value="http://www.exoplatform.org/jcr/test/1.0"/>
+ <property name="rma"
value="http://www.rma.com/jcr/"/>
+ <property name="metadata"
value="http://www.exoplatform.com/jcr/metadata/1.1/"/>
+ </properties-param>
</init-params>
- </component-plugin>
- <component-plugin>
- <name>add.nodeType</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.jcr.impl.AddNodeTypePlugin</type>
- <init-params>
- <values-param>
- <name>autoCreatedInNewRepository</name>
- <description>Node types configuration file</description>
- <value>jar:/conf/test/nodetypes-tck.xml</value>
- <value>jar:/conf/test/nodetypes-impl.xml</value>
- <value>jar:/conf/test/nodetypes-usecase.xml</value>
-
<value>jar:/conf/test/nodetypes-config-extended.xml</value>
- </values-param>
- <values-param>
- <name>testInitNodeTypesRepository</name>
- <description>Node types configuration file for repository with
name testInitNodeTypesRepository</description>
- <value>jar:/conf/test/nodetypes-test.xml</value>
- </values-param>
- <values-param>
- <name>testInitNodeTypesRepositoryTest2</name>
- <description>Node types configuration file for repository with
name testInitNodeTypesRepositoryTest2</description>
- <value>jar:/conf/test/nodetypes-test2.xml</value>
- </values-param>
- </init-params>
- </component-plugin>
+ </component-plugin>
+ <component-plugin>
+ <name>add.nodeType</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.jcr.impl.AddNodeTypePlugin</type>
+ <init-params>
+ <values-param>
+ <name>autoCreatedInNewRepository</name>
+ <description>Node types configuration file</description>
+ <value>jar:/conf/test/nodetypes-tck.xml</value>
+ <value>jar:/conf/test/nodetypes-impl.xml</value>
+ <value>jar:/conf/test/nodetypes-usecase.xml</value>
+ <value>jar:/conf/test/nodetypes-config.xml</value>
+ <value>jar:/conf/test/nodetypes-config-extended.xml</value>
+ </values-param>
+ <values-param>
+ <name>testInitNodeTypesRepository</name>
+ <description>Node types configuration file for repository with name
testInitNodeTypesRepository</description>
+ <value>jar:/conf/test/nodetypes-test.xml</value>
+ </values-param>
+ <values-param>
+ <name>testInitNodeTypesRepositoryTest2</name>
+ <description>Node types configuration file for repository with name
testInitNodeTypesRepositoryTest2</description>
+ <value>jar:/conf/test/nodetypes-test2.xml</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
</component-plugins>
- </component>
+ </component>
- <component>
-
<key>org.exoplatform.services.jcr.config.RepositoryServiceConfiguration</key>
-
<type>org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl</type>
- <init-params>
- <value-param>
- <name>conf-path</name>
- <description>JCR configuration file</description>
- <value>jar:/conf/standalone/test-jcr-config-sjdbc.xml</value>
- </value-param>
- </init-params>
- </component>
+ <component>
+
<key>org.exoplatform.services.jcr.config.RepositoryServiceConfiguration</key>
+
<type>org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl</type>
+ <init-params>
+ <value-param>
+ <name>conf-path</name>
+ <description>JCR configuration file</description>
+ <value>jar:/conf/standalone/test-jcr-config-sjdbc.xml</value>
+ </value-param>
+ </init-params>
+ </component>
- <component>
-
<type>org.exoplatform.services.organization.impl.mock.DummyOrganizationService</type>
- </component>
- <component>
- <key>org.exoplatform.services.security.Authenticator</key>
-
<type>org.exoplatform.services.organization.auth.OrganizationAuthenticatorImpl</type>
- </component>
- <component>
+ <component>
+
<type>org.exoplatform.services.organization.impl.mock.DummyOrganizationService</type>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.security.Authenticator</key>
+
<type>org.exoplatform.services.organization.auth.OrganizationAuthenticatorImpl</type>
+ </component>
+
+ <component>
<type>org.exoplatform.services.jcr.impl.ext.action.SessionActionCatalog</type>
- </component>
+ </component>
- <component>
+ <component>
<key>org.exoplatform.services.transaction.TransactionService</key>
<type>org.exoplatform.services.transaction.impl.jotm.TransactionServiceJotmImpl</type>
<init-params>
- <value-param>
- <name>timeout</name>
- <value>5</value>
- </value-param>
+ <value-param>
+ <name>timeout</name>
+ <value>5</value>
+ </value-param>
</init-params>
- </component>
+ </component>
- <external-component-plugins>
-
<target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component>
+ <external-component-plugins>
+
<target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component>
<component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver" />
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/portal" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:target/temp/data/portal"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcrtest</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jcrtest"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr3</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jcr3"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
<component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcrtck</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver" />
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/portaltck" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <!-- Resource configuration for UserTransaction
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcrtck</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:target/temp/data/portaltck"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <!-- Resource configuration for UserTransaction
use JOTM
-->
<component-plugin>
- <name>jotm.tx</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>UserTransaction</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.transaction.UserTransaction</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.objectweb.jotm.UserTransactionFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="jotm.timeout" value="60" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.jcr</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>repo</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.jcr.Repository</value>
- </value-param>
- <value-param>
- <name>factory</name>
-
<value>org.exoplatform.services.jcr.impl.jndi.BindableRepositoryFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="repositoryName" value="db1" />
- <!-- property name="containerConfig"
value="exo-configuration.xml"/ -->
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>rmi.jcr</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>rmirepository</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.jcr.Repository</value>
- </value-param>
- <value-param>
- <name>factory</name>
-
<value>org.exoplatform.services.jcr.rmi.RepositoryFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="url"
value="//localhost:9999/repository" />
- </properties-param>
- </init-params>
- </component-plugin>
- </external-component-plugins>
+ <name>jotm.tx</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>UserTransaction</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.transaction.UserTransaction</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.objectweb.jotm.UserTransactionFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="jotm.timeout" value="60"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.jcr</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>repo</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.jcr.Repository</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+
<value>org.exoplatform.services.jcr.impl.jndi.BindableRepositoryFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="repositoryName" value="db1"/>
+ <!-- property name="containerConfig"
value="exo-configuration.xml"/ -->
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>rmi.jcr</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>rmirepository</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.jcr.Repository</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+
<value>org.exoplatform.services.jcr.rmi.RepositoryFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="url"
value="//localhost:9999/repository"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
-
<remove-configuration>org.exoplatform.services.scheduler.JobSchedulerService</remove-configuration>
- <!--<import>jar:/conf/database-configuration.hsql.xml</import> -->
+
<remove-configuration>org.exoplatform.services.scheduler.JobSchedulerService</remove-configuration>
+ <!--<import>jar:/conf/database-configuration.hsql.xml</import> -->
</configuration>
Modified: jcr/trunk/component/core/src/test/java/conf/standalone/test-configuration.xml
===================================================================
---
jcr/trunk/component/core/src/test/java/conf/standalone/test-configuration.xml 2009-08-28
06:34:31 UTC (rev 24)
+++
jcr/trunk/component/core/src/test/java/conf/standalone/test-configuration.xml 2009-08-28
06:54:41 UTC (rev 25)
@@ -1,497 +1,541 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
+<configuration
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd
http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
+ <component>
+ <key>org.exoplatform.services.log.LogConfigurationInitializer</key>
+ <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
+ <init-params>
+ <value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedLog4JLogger</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.Log4JConfigurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>Log4J properties</description>
+ <property name="log4j.rootLogger" value="INFO, stdout,
file"/>
+
+ <property name="log4j.appender.stdout"
value="org.apache.log4j.ConsoleAppender"/>
+ <property name="log4j.appender.stdout.threshold"
value="DEBUG"/>
+
+ <property name="log4j.appender.stdout.layout"
value="org.apache.log4j.PatternLayout"/>
+ <property name="log4j.appender.stdout.layout.ConversionPattern"
+ value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L)
%n"/>
+
+ <property name="log4j.appender.file"
value="org.apache.log4j.FileAppender"/>
+ <property name="log4j.appender.file.File"
value="target/jcr.log"/>
+
+ <property name="log4j.appender.file.layout"
value="org.apache.log4j.PatternLayout"/>
+ <property name="log4j.appender.file.layout.ConversionPattern"
+ value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L)
%n"/>
+
+ <property name="log4j.category.jcr.FileCleaner"
value="DEBUG"/>
+
+ <!-- property name="log4j.category.jcr.JDBCStorageConnection"
value="DEBUG"/>
+ <property name="log4j.category.jcr.NodeImpl"
value="DEBUG"/ -->
+
+ <!-- property name="log4j.category.jcr.WorkspaceStorageCacheImpl"
value="DEBUG"/ -->
+ <!-- property name="log4j.category.database.DBSchemaCreator"
value="DEBUG"/ -->
+ <!-- property name="log4j.category.jcr.WorkspaceDataReplicator"
value="DEBUG"/ -->
+
+ <!-- property name="log4j.category.jcr.WorkspaceStorageCacheImpl"
value="DEBUG"/ -->
+ <!-- property
name="log4j.category.jcr.WorkspacePersistentDataManager"
value="DEBUG"/ -->
+ <!-- property name="log4j.category.jcr.SessionDataManager"
value="DEBUG"/ -->
+ </properties-param>
+
+ <!-- value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedSimpleLog</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.SimpleLogConfigurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>SimpleLog properties</description>
+ <property name="org.apache.commons.logging.simplelog.defaultlog"
value="debug"/>
+ <property name="org.apache.commons.logging.simplelog.showdatetime"
value="true"/>
+ </properties-param -->
+
+ <!-- value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedJdk14Logger</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.Jdk14Configurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>jdk1.4 Logger properties</description>
+ <property name="handlers"
value="java.util.logging.ConsoleHandler"/>
+ <property name=".level" value="FINE"/>
+ <property name="java.util.logging.ConsoleHandler.level"
value="FINE"/>
+ </properties-param -->
+
+ </init-params>
+ </component>
- 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.
-
--->
-<configuration
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd
http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
-
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
- <component>
- <key>org.exoplatform.services.log.LogConfigurationInitializer</key>
- <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
+ <component>
+ <key>org.exoplatform.services.jcr.RepositoryService</key>
+ <type>org.exoplatform.services.jcr.impl.RepositoryServiceImpl</type>
+ <component-plugins>
+ <component-plugin>
+ <name>add.namespaces</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.jcr.impl.AddNamespacesPlugin</type>
+ <init-params>
+ <properties-param>
+ <name>namespaces</name>
+ <property name="test"
value="http://www.apache.org/jackrabbit/test"/>
+ <property name="exojcrtest"
value="http://www.exoplatform.org/jcr/test/1.0"/>
+ <property name="rma"
value="http://www.rma.com/jcr/"/>
+ <property name="metadata"
value="http://www.exoplatform.com/jcr/metadata/1.1/"/>
+ <property name="dc"
value="http://purl.org/dc/elements/1.1/"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>add.nodeType</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.jcr.impl.AddNodeTypePlugin</type>
+ <init-params>
+ <values-param>
+ <name>autoCreatedInNewRepository</name>
+ <description>Node types configuration file</description>
+ <value>jar:/conf/test/nodetypes-tck.xml</value>
+ <value>jar:/conf/test/nodetypes-impl.xml</value>
+ <value>jar:/conf/test/nodetypes-usecase.xml</value>
+ <value>jar:/conf/test/nodetypes-config.xml</value>
+ <value>jar:/conf/test/nodetypes-config-extended.xml</value>
+ </values-param>
+
+ <values-param>
+ <name>testInitNodeTypesRepository</name>
+ <description>
+ Node types configuration file for repository with name
testInitNodeTypesRepository
+ </description>
+ <value>jar:/conf/test/nodetypes-test.xml</value>
+ </values-param>
+
+ <values-param>
+ <name>testInitNodeTypesRepositoryTest2</name>
+ <description>
+ Node types configuration file for repository with name
testInitNodeTypesRepositoryTest2
+ </description>
+ <value>jar:/conf/test/nodetypes-test2.xml</value>
+ </values-param>
+
+ <!--values-param>
+ <name>testInitNodeTypesRepositoryTest3</name>
+ <description>Node types from ext. Needed bacause core starup earlie than
ext</description>
+ <value>jar:/conf/test/nodetypes-test3_ext.xml</value>
+ </values-param-->
+
+ </init-params>
+ </component-plugin>
+ </component-plugins>
+ </component>
+
+ <component>
+
<key>org.exoplatform.services.jcr.config.RepositoryServiceConfiguration</key>
+
<type>org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl</type>
+ <init-params>
+ <value-param>
+ <name>conf-path</name>
+ <description>JCR configuration file</description>
+ <value>jar:/conf/standalone/test-jcr-config.xml</value>
+ </value-param>
+ <properties-param>
+ <name>working-conf</name>
+ <description>working-conf</description>
+ <property name="source-name" value="jdbcjcr"/>
+ <property name="dialect" value="hsqldb"/>
+ <property name="persister-class-name"
value="org.exoplatform.services.jcr.impl.config.JDBCConfigurationPersister"/>
+ </properties-param>
+ </init-params>
+ </component>
+
+ <component>
+
<type>org.exoplatform.services.organization.impl.mock.DummyOrganizationService</type>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.security.Authenticator</key>
+
<type>org.exoplatform.services.organization.auth.OrganizationAuthenticatorImpl</type>
+ </component>
+
+ <component>
+
<type>org.exoplatform.services.jcr.impl.ext.action.SessionActionCatalog</type>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.transaction.TransactionService</key>
+
<type>org.exoplatform.services.transaction.impl.jotm.TransactionServiceJotmImpl</type>
+ <init-params>
+ <value-param>
+ <name>timeout</name>
+ <value>5</value>
+ </value-param>
+ </init-params>
+ </component>
+
+ <external-component-plugins>
+
<target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
<init-params>
- <value-param>
- <name>logger</name>
-
<value>org.exoplatform.services.log.impl.BufferedLog4JLogger</value>
- </value-param>
- <value-param>
- <name>configurator</name>
-
<value>org.exoplatform.services.log.impl.Log4JConfigurator</value>
- </value-param>
- <properties-param>
- <name>properties</name>
- <description>Log4J properties</description>
- <property name="log4j.rootLogger" value="INFO, stdout,
file" />
-
- <property name="log4j.appender.stdout"
value="org.apache.log4j.ConsoleAppender" />
- <property name="log4j.appender.stdout.threshold"
value="DEBUG" />
-
- <property name="log4j.appender.stdout.layout"
value="org.apache.log4j.PatternLayout" />
- <property name="log4j.appender.stdout.layout.ConversionPattern"
value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
-
- <property name="log4j.appender.file"
value="org.apache.log4j.FileAppender" />
- <property name="log4j.appender.file.File"
value="target/jcr.log" />
-
- <property name="log4j.appender.file.layout"
value="org.apache.log4j.PatternLayout" />
- <property name="log4j.appender.file.layout.ConversionPattern"
value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
-
- <property name="log4j.category.jcr.FileCleaner"
value="DEBUG" />
-
- <!-- property name="log4j.category.jcr.JDBCStorageConnection"
value="DEBUG" / -->
- <!-- property name="log4j.category.jcr.NodeImpl"
value="DEBUG" / -->
-
- <!-- property
name="log4j.category.jcr.WorkspaceStorageCacheImpl" value="DEBUG"/
-->
- <!-- property name="log4j.category.database.DBSchemaCreator"
value="DEBUG"/ -->
- <!-- property name="log4j.category.jcr.WorkspaceDataReplicator"
value="DEBUG"/ -->
-
- <!-- property
name="log4j.category.jcr.WorkspaceStorageCacheImpl" value="DEBUG"/
-->
- <!-- property
name="log4j.category.jcr.WorkspacePersistentDataManager"
value="DEBUG"/ -->
- <!-- property name="log4j.category.jcr.SessionDataManager"
value="DEBUG"/ -->
- </properties-param>
-
- <!-- value-param>
- <name>logger</name>
-
<value>org.exoplatform.services.log.impl.BufferedSimpleLog</value>
- </value-param>
- <value-param>
- <name>configurator</name>
-
<value>org.exoplatform.services.log.impl.SimpleLogConfigurator</value>
- </value-param>
- <properties-param>
- <name>properties</name>
- <description>SimpleLog properties</description>
- <property name="org.apache.commons.logging.simplelog.defaultlog"
value="debug" />
- <property
name="org.apache.commons.logging.simplelog.showdatetime" value="true"
/>
- </properties-param -->
-
- <!-- value-param>
- <name>logger</name>
-
<value>org.exoplatform.services.log.impl.BufferedJdk14Logger</value>
- </value-param>
- <value-param>
- <name>configurator</name>
-
<value>org.exoplatform.services.log.impl.Jdk14Configurator</value>
- </value-param>
- <properties-param>
- <name>properties</name>
- <description>jdk1.4 Logger properties</description>
- <property name="handlers"
value="java.util.logging.ConsoleHandler" />
- <property name=".level" value="FINE" />
- <property name="java.util.logging.ConsoleHandler.level"
value="FINE" />
- </properties-param -->
-
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:target/temp/data/portal"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
</init-params>
- </component>
-
- <component>
- <key>org.exoplatform.services.jcr.RepositoryService</key>
- <type>org.exoplatform.services.jcr.impl.RepositoryServiceImpl</type>
- <component-plugins>
- <component-plugin>
- <name>add.namespaces</name>
- <set-method>addPlugin</set-method>
-
<type>org.exoplatform.services.jcr.impl.AddNamespacesPlugin</type>
- <init-params>
- <properties-param>
- <name>namespaces</name>
- <property name="test"
value="http://www.apache.org/jackrabbit/test" />
- <property name="exojcrtest"
value="http://www.exoplatform.org/jcr/test/1.0" />
- <property name="rma"
value="http://www.rma.com/jcr/" />
- <property name="metadata"
value="http://www.exoplatform.com/jcr/metadata/1.1/" />
- <property name="dc"
value="http://purl.org/dc/elements/1.1/" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>add.nodeType</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.jcr.impl.AddNodeTypePlugin</type>
- <init-params>
- <values-param>
- <name>autoCreatedInNewRepository</name>
- <description>Node types configuration file</description>
- <value>jar:/conf/test/nodetypes-tck.xml</value>
- <value>jar:/conf/test/nodetypes-impl.xml</value>
- <value>jar:/conf/test/nodetypes-usecase.xml</value>
- <value>jar:/conf/test/nodetypes-config.xml</value>
-
<value>jar:/conf/test/nodetypes-config-extended.xml</value>
- </values-param>
-
- <values-param>
- <name>testInitNodeTypesRepository</name>
- <description>Node types configuration file for repository with
name testInitNodeTypesRepository</description>
- <value>jar:/conf/test/nodetypes-test.xml</value>
- </values-param>
-
- <values-param>
- <name>testInitNodeTypesRepositoryTest2</name>
- <description>Node types configuration file for repository with
name testInitNodeTypesRepositoryTest2</description>
- <value>jar:/conf/test/nodetypes-test2.xml</value>
- </values-param>
-
- <!-- values-param>
- <name>testInitNodeTypesRepositoryTest3</name>
- <description>Node types from ext. Needed bacause core starup
earlie than ext</description>
- <value>jar:/conf/test/nodetypes-test3_ext.xml</value>
- </values-param -->
-
- </init-params>
- </component-plugin>
- </component-plugins>
- </component>
-
- <component>
-
<key>org.exoplatform.services.jcr.config.RepositoryServiceConfiguration</key>
-
<type>org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl</type>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
<init-params>
- <value-param>
- <name>conf-path</name>
- <description>JCR configuration file</description>
- <value>jar:/conf/standalone/test-jcr-config.xml</value>
- </value-param>
- <properties-param>
- <name>working-conf</name>
- <description>working-conf</description>
- <property name="source-name" value="jdbcjcr" />
- <property name="dialect" value="hsqldb" />
- <property name="persister-class-name"
value="org.exoplatform.services.jcr.impl.config.JDBCConfigurationPersister"
/>
- </properties-param>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr1</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jcr"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
</init-params>
- </component>
-
- <component>
-
<type>org.exoplatform.services.organization.impl.mock.DummyOrganizationService</type>
- </component>
-
- <component>
- <key>org.exoplatform.services.security.Authenticator</key>
-
<type>org.exoplatform.services.organization.auth.OrganizationAuthenticatorImpl</type>
- </component>
-
- <component>
-
<type>org.exoplatform.services.jcr.impl.ext.action.SessionActionCatalog</type>
- </component>
-
- <component>
- <key>org.exoplatform.services.transaction.TransactionService</key>
-
<type>org.exoplatform.services.transaction.impl.jotm.TransactionServiceJotmImpl</type>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
<init-params>
- <value-param>
- <name>timeout</name>
- <value>5</value>
- </value-param>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr2</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jcr2"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
</init-params>
- </component>
-
- <external-component-plugins>
-
<target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver" />
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/portal" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr1</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver" />
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jcr" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr2</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver" />
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jcr2" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcrtck</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver" />
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/portaltck" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr1tck</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver" />
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jcrtck" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr2tck</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver" />
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jcr2tck" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr2export1</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver" />
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jdbcjcr2export1" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr2export2</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver" />
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jdbcjcr2export2" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <!-- Resource configuration for UserTransaction use JOTM -->
- <component-plugin>
- <name>jotm.tx</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>UserTransaction</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.transaction.UserTransaction</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.objectweb.jotm.UserTransactionFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="jotm.timeout" value="60" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.jcr</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>repo</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.jcr.Repository</value>
- </value-param>
- <value-param>
- <name>factory</name>
-
<value>org.exoplatform.services.jcr.impl.jndi.BindableRepositoryFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="repositoryName" value="db1" />
- <!-- property name="containerConfig"
value="exo-configuration.xml"/ -->
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>rmi.jcr</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>rmirepository</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.jcr.Repository</value>
- </value-param>
- <value-param>
- <name>factory</name>
-
<value>org.exoplatform.services.jcr.rmi.RepositoryFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="url"
value="//localhost:9999/repository" />
- </properties-param>
- </init-params>
- </component-plugin>
- </external-component-plugins>
-
-
<remove-configuration>org.exoplatform.services.scheduler.JobSchedulerService</remove-configuration>
- <!--<import>jar:/conf/database-configuration.hsql.xml</import> -->
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr3</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jcr3"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcrtest</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jcrtest"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcrtck</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:target/temp/data/portaltck"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr1tck</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jcrtck"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr2tck</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jcr2tck"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr2export1</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jdbcjcr2export1"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr2export2</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jdbcjcr2export2"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <!-- Resource configuration for UserTransaction
+ use JOTM
+ -->
+ <component-plugin>
+ <name>jotm.tx</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>UserTransaction</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.transaction.UserTransaction</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.objectweb.jotm.UserTransactionFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="jotm.timeout" value="60"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.jcr</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>repo</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.jcr.Repository</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+
<value>org.exoplatform.services.jcr.impl.jndi.BindableRepositoryFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="repositoryName" value="db1"/>
+ <!-- property name="containerConfig"
value="exo-configuration.xml"/ -->
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>rmi.jcr</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>rmirepository</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.jcr.Repository</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.exoplatform.services.jcr.rmi.RepositoryFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="url"
value="//localhost:9999/repository"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+
+
<remove-configuration>org.exoplatform.services.scheduler.JobSchedulerService</remove-configuration>
+ <!--<import>jar:/conf/database-configuration.hsql.xml</import> -->
</configuration>
Added:
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCConnectionTestBase.java
===================================================================
---
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCConnectionTestBase.java
(rev 0)
+++
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCConnectionTestBase.java 2009-08-28
06:54:41 UTC (rev 25)
@@ -0,0 +1,270 @@
+/*
+ * Copyright (C) 2003-2007 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.storage.jdbc;
+
+import java.io.ByteArrayInputStream;
+import java.sql.*;
+
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+
+import org.exoplatform.services.jcr.JcrAPIBaseTest;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
+import org.exoplatform.services.jcr.impl.storage.jdbc.init.DBInitializer;
+
+/**
+ * Created by The eXo Platform SAS
+ *
+ * 01.07.2009
+ *
+ * @author <a href="mailto:dezder@bk.ru">Denis Grebenyuk</a>
+ * @version $Id:$
+ */
+abstract public class JDBCConnectionTestBase extends JcrAPIBaseTest {
+
+ protected JDBCStorageConnection jdbcConn = null;
+ protected String tableType = null;
+ private Connection connect = null;
+
+ public void setUp(String scriptPath, boolean multiDB) throws Exception {
+
+ super.setUp();
+ new DBInitializer("ws3", getJNDIConnection(), scriptPath, multiDB)
+ .init();
+ }
+
+ protected void tearDown() throws Exception {
+
+ connect.close();
+ super.tearDown();
+ }
+
+ public Connection getJNDIConnection() throws Exception {
+
+ DataSource ds = (DataSource) new InitialContext().lookup("jdbcjcrtest");
+ connect = ds.getConnection();
+ return connect;
+ }
+
+ private NodeData setNode() throws Exception {
+ InternalQName[] iqn = { InternalQName.parse("[]DbJDBCConnectionTest") };
+ TransientNodeData tnd = new TransientNodeData(
+ Constants.JCR_NODETYPES_PATH, "Z", 9, Constants.SV_NODE_NAME,
+ iqn, 8, null, null);
+ return tnd;
+ }
+
+ private NodeData giveNodeForRename() throws Exception {
+
+ InternalQName[] iqn = { InternalQName.parse("[]DbJDBCConnectionTest") };
+ TransientNodeData tnd = new TransientNodeData(
+ Constants.JCR_NODETYPES_PATH, "B", 9, Constants.SV_NODE_NAME,
+ iqn, 8, null, null);
+ return tnd;
+ }
+
+ public void testAddNode() throws Exception {
+
+ jdbcConn.add(setNode());
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "ITEM"
+ + " where N_ORDER_NUM=8");
+ rs.next();
+
assertEquals("[http://www.jcp.org/jcr/1.0]nodetypes", rs
+ .getString("NAME"));
+ }
+
+ public void testAddValueData() throws Exception {
+
+ byte data[] = { 5 };
+ ByteArrayInputStream bas = new ByteArrayInputStream(data);
+ jdbcConn.addValueData("C", 2, bas, 2, "J");
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "VALUE"
+ + " where PROPERTY_ID='C'");
+ rs.next();
+ assertEquals("05", rs.getString("DATA"));
+ }
+
+ public void testRenameNode() throws Exception {
+
+ jdbcConn.renameNode(giveNodeForRename());
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "ITEM"
+ + " where N_ORDER_NUM=8");
+ rs.next();
+
assertEquals("[http://www.jcp.org/jcr/1.0]nodetypes", rs
+ .getString("NAME"));
+ }
+
+ public void testUpdateNodeByIdentifier() throws Exception {
+
+ jdbcConn.updateNodeByIdentifier(200923, 4512, 20, "B");
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "ITEM"
+ + " where ID='B'");
+ rs.next();
+ assertEquals(20, rs.getInt("N_ORDER_NUM"));
+ }
+
+ public void testUpdatePropertyByIdentifier() throws Exception {
+
+ jdbcConn.updatePropertyByIdentifier(200923, 4512, "C");
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "ITEM"
+ + " where ID='C'");
+ rs.next();
+ assertEquals(4512, rs.getInt("P_TYPE"));
+ }
+
+ public void testDeleteReference() throws Exception {
+
+ jdbcConn.deleteReference("A");
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "REF"
+ + " where PROPERTY_ID='A'");
+ assertEquals(false, rs.next());
+ }
+
+ public void testDeleteItemByIdentifier() throws Exception {
+
+ jdbcConn.deleteItemByIdentifier("C");
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "ITEM"
+ + " where ID='C'");
+ assertEquals(false, rs.next());
+ }
+
+ public void testDeleteValueData() throws Exception {
+
+ jdbcConn.deleteValueData("A");
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "VALUE"
+ + " where PROPERTY_ID='A'");
+ assertEquals(false, rs.next());
+ }
+
+ public void testFindItemByIdentifier() throws Exception {
+
+ ResultSet rsRemote = jdbcConn.findItemByIdentifier("A");
+ rsRemote.next();
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "ITEM"
+ + " where ID='A'");
+ rs.next();
+ assertEquals(rsRemote.getString("PARENT_ID"),
rs.getString("PARENT_ID"));
+ }
+
+ public void testFindPropertyByName() throws Exception {
+
+ ResultSet rsRemote = jdbcConn.findPropertyByName("A", "test1");
+ rsRemote.next();
+ ResultSet rs = connect
+ .createStatement()
+ .executeQuery(
+ "select V.DATA from JCR_"
+ + tableType
+ + "ITEM I, JCR_"
+ + tableType
+ + "VALUE V "
+ + "where I.I_CLASS=2 and I.PARENT_ID='A' and I.NAME='test1'
and I.ID=V.PROPERTY_ID order by V.ORDER_NUM");
+ rs.next();
+ assertEquals(rsRemote.getString("DATA"), rs.getString("DATA"));
+ }
+
+ public void testFindItemByName() throws Exception {
+
+ ResultSet rsRemote = jdbcConn.findItemByName("A", "test1", 1233);
+ rsRemote.next();
+ ResultSet rs = connect
+ .createStatement()
+ .executeQuery(
+ "select * from JCR_"
+ + tableType
+ + "ITEM"
+ + " where PARENT_ID='A' and NAME='test1' and I_INDEX=1233
order by I_CLASS, VERSION DESC");
+ rs.next();
+ assertEquals(rsRemote.getString("ID"), rs.getString("ID"));
+ }
+
+ public void testFindChildNodesByParentIdentifier() throws Exception {
+
+ ResultSet rsRemote = jdbcConn.findChildNodesByParentIdentifier("A");
+ rsRemote.next();
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "ITEM"
+ + " where I_CLASS=1 and PARENT_ID='A'");
+ rs.next();
+ assertEquals(rsRemote.getString("NAME"), rs.getString("NAME"));
+ }
+
+ public void testFindChildPropertiesByParentIdentifier() throws Exception {
+ ResultSet rsRemote = jdbcConn
+ .findChildPropertiesByParentIdentifier("A");
+ rsRemote.next();
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from JCR_" + tableType + "ITEM"
+ + " where I_CLASS=2 and PARENT_ID='A' order by ID");
+ rs.next();
+ assertEquals(rsRemote.getString("NAME"), rs.getString("NAME"));
+ }
+
+ public void testFindReferences() throws Exception {
+
+ ResultSet rsRemote = jdbcConn.findReferences("D");
+ rsRemote.next();
+ ResultSet rs = connect
+ .createStatement()
+ .executeQuery(
+ "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME"
+ + " from JCR_"
+ + tableType
+ + "REF R, JCR_"
+ + tableType
+ + "ITEM P"
+ + " where R.NODE_ID='D' and P.ID=R.PROPERTY_ID and
P.I_CLASS=2");
+ rs.next();
+ assertEquals(rsRemote.getString("ID"), rs.getString("ID"));
+ }
+
+ public void testFindValuesByPropertyId() throws Exception {
+
+ ResultSet rsRemote = jdbcConn.findValuesByPropertyId("A");
+ rsRemote.next();
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select PROPERTY_ID, ORDER_NUM, STORAGE_DESC from " + "JCR_"
+ + tableType + "VALUE"
+ + " where PROPERTY_ID='A' order by ORDER_NUM");
+ rs.next();
+ assertEquals(rsRemote.getString("STORAGE_DESC"), rs
+ .getString("STORAGE_DESC"));
+ }
+
+ public void testFindValueByPropertyIdOrderNumber() throws Exception {
+
+ ResultSet rsRemote = jdbcConn.findValueByPropertyIdOrderNumber("A", 16);
+ rsRemote.next();
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select DATA from " + "JCR_" + tableType + "VALUE"
+ + " where PROPERTY_ID='A' and ORDER_NUM=16");
+ rs.next();
+ assertEquals(rsRemote.getString("DATA"), rs.getString("DATA"));
+ }
+}
Property changes on:
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCConnectionTestBase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java
===================================================================
---
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java
(rev 0)
+++
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java 2009-08-28
06:54:41 UTC (rev 25)
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2003-2007 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.storage.jdbc.db;
+
+import java.sql.*;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCConnectionTestBase;
+
+/**
+ * Created by The eXo Platform SAS
+ *
+ * 01.07.2009
+ *
+ * @author <a href="mailto:dezder@bk.ru">Denis Grebenyuk</a>
+ * @version $Id:$
+ */
+public class TestMultiDbJDBCConnection extends JDBCConnectionTestBase {
+
+ /* (non-Javadoc)
+ * @see org.exoplatform.services.jcr.BaseStandaloneTest#setUp()
+ */
+ @Override
+ public void setUp() throws Exception {
+ super.setUp("/conf/storage/jcr-mjdbc.sql",true);
+ try {
+
+ Statement st = getJNDIConnection().createStatement();
+ st.executeUpdate("insert into JCR_MITEM values"
+ + "('A','A','test1',20090525,2,1233,5,10,1)");
+ st.executeUpdate("insert into JCR_MITEM values"
+ + "('B','A','test2',20090625,1,1233,5,10,1)");
+ st.executeUpdate("insert into JCR_MITEM values"
+ + "('C','B','test3',20090825,1,1233,5,10,1)");
+ st
+ .executeUpdate("insert into JCR_MVALUE(DATA,ORDER_NUM,PROPERTY_ID,STORAGE_DESC)
values"
+ + "('0xfa',16,'A','testConn')");
+ st
+ .executeUpdate("insert into JCR_MVALUE(DATA,ORDER_NUM,PROPERTY_ID,STORAGE_DESC)
values"
+ + "('0xce',16,'B','testConn2')");
+ st.executeUpdate("insert into JCR_MREF values" +
"('D','A',2)");
+ st.executeUpdate("insert into JCR_MREF values" +
"('E','B',2)");
+ jdbcConn = new MultiDbJDBCConnection(getJNDIConnection(), false, "ws3",
null, 10, null,
+ null);
+ tableType = "M";
+ st.close();
+ } catch (SQLException se) {
+
+ fail(se.toString());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.exoplatform.services.jcr.impl.storage.jdbc.JDBCConnectionTestBase#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception {
+
+ try {
+
+ Statement st = getJNDIConnection().createStatement();
+ st.executeUpdate("drop table JCR_MREF");
+ st.executeUpdate("drop table JCR_MVALUE");
+ st.executeUpdate("drop table JCR_MITEM");
+ st.close();
+
+ } catch (SQLException se) {
+ fail(se.toString());
+ }
+ super.tearDown();
+ }
+}
\ No newline at end of file
Property changes on:
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java
===================================================================
---
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java
(rev 0)
+++
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java 2009-08-28
06:54:41 UTC (rev 25)
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2003-2007 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.storage.jdbc.db;
+
+import java.sql.SQLException;
+import java.sql.Statement;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCConnectionTestBase;
+
+/**
+ * Created by The eXo Platform SAS
+ *
+ * 01.07.2009
+ *
+ * @author <a href="mailto:dezder@bk.ru">Denis Grebenyuk</a>
+ * @version $Id:$
+ */
+public class TestSingleDbJDBCConnection extends JDBCConnectionTestBase {
+
+ /* (non-Javadoc)
+ * @see org.exoplatform.services.jcr.BaseStandaloneTest#setUp()
+ */
+ @Override
+ public void setUp() throws Exception {
+ super.setUp("/conf/storage/jcr-sjdbc.sql",false);
+ try {
+
+ Statement st = getJNDIConnection().createStatement();
+ st.executeUpdate("insert into JCR_SITEM values"
+ +
"('A','A','test1',20090525,'ws3',2,1233,1,10,5)");
+ st.executeUpdate("insert into JCR_SITEM values"
+ +
"('B','A','test2',20090625,'ws3',1,1233,5,10,4)");
+ st.executeUpdate("insert into JCR_SITEM values"
+ +
"('C','B','test3',20090825,'ws3',1,1233,5,10,2)");
+ st.executeUpdate("insert into JCR_SITEM values"
+ +
"('ws3B','A','test4',2009525,'ws3',2,1233,1,10,5)");
+ st
+ .executeUpdate("insert into JCR_SVALUE(DATA,ORDER_NUM,PROPERTY_ID,STORAGE_DESC)
values"
+ + "('0xfa',16,'A','testConn')");
+ st
+ .executeUpdate("insert into JCR_SVALUE(DATA,ORDER_NUM,PROPERTY_ID,STORAGE_DESC)
values"
+ + "('0xce',16,'B','testConn2')");
+ st.executeUpdate("insert into JCR_SREF values" +
"('D','A',2)");
+ st.executeUpdate("insert into JCR_SREF values" +
"('E','B',2)");
+ st.close();
+ jdbcConn = new SingleDbJDBCConnection(getJNDIConnection(), false, "ws3",
null,
+ 10, null, null);
+ tableType = "S";
+
+ } catch (SQLException se) {
+ fail(se.toString());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.exoplatform.services.jcr.impl.storage.jdbc.JDBCConnectionTestBase#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception {
+
+ try {
+ Statement st = getJNDIConnection().createStatement();
+ st.executeUpdate("drop table JCR_SREF");
+ st.executeUpdate("drop table JCR_SVALUE");
+ st.executeUpdate("drop table JCR_SITEM");
+ st.close();
+ } catch (SQLException se) {
+ fail(se.toString());
+ }
+ super.tearDown();
+ }
+}
\ No newline at end of file
Property changes on:
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain