exo-jcr SVN: r2087 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation: db and 1 other directory.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-03-19 13:45:28 -0400 (Fri, 19 Mar 2010)
New Revision: 2087
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleMultiDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
Log:
EXOJCR-519:
A. FIND_REFERENCE_PROPERTIES_CQ has been removed because:
1. To be improved on Oracle we need to add indexes which will impact the performances of the write operation
2. This method is not critical in term of business value since it is not used too often
3. This method doesn't need to be scalable in term of total amount of results since we should never have more than 10 properties
4. This method seems to cause deadlocks on PostgresSQL
B. The hints were not correct for oracle in multidb mode
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2010-03-19 15:20:47 UTC (rev 2086)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2010-03-19 17:45:28 UTC (rev 2087)
@@ -31,7 +31,6 @@
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.ByteArrayPersistedValueData;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
import org.exoplatform.services.jcr.impl.storage.jdbc.PrimaryTypeNotFoundException;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
@@ -88,11 +87,6 @@
protected String FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ;
/**
- * FIND_REFERENCE_PROPERTIES_CQ.
- */
- protected String FIND_REFERENCE_PROPERTIES_CQ;
-
- /**
* FIND_ITEM_QPATH_BY_ID_CQ.
*/
protected String FIND_ITEM_QPATH_BY_ID_CQ;
@@ -352,152 +346,6 @@
}
/**
- * {@inheritDoc}
- */
- public List<PropertyData> getReferencesData(String nodeIdentifier) throws RepositoryException, IllegalStateException
- {
- checkIfOpened();
- ResultSet refProps = null;
- try
- {
- refProps = findReferencePropertiesCQ(getInternalId(nodeIdentifier));
- return loadReferences(refProps);
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- finally
- {
- if (refProps != null)
- {
- try
- {
- refProps.close();
- }
- catch (SQLException e)
- {
- LOG.error(e.getMessage(), e);
- }
- }
- }
-
- }
-
- /**
- * Load Property references
- *
- * @param resultSet
- * @return
- * @throws RepositoryException
- * @throws SQLException
- * @throws IOException
- */
- private List<PropertyData> loadReferences(ResultSet resultSet) throws RepositoryException, SQLException, IOException
- {
- List<PropertyData> resultProps = new ArrayList<PropertyData>();
-
- // Property Id and amount of copies in result
- Map<String, Integer> dublicatedProps = new HashMap<String, Integer>();
- Map<String, PersistedPropertyData> propertyBuffer = new HashMap<String, PersistedPropertyData>();
- Map<String, List<ValueData>> valuesBuffer = new HashMap<String, List<ValueData>>();
-
- try
- {
- while (resultSet.next())
- {
- String cid = resultSet.getString(COLUMN_ID);
- String identifier = getIdentifier(cid);
-
- int cversion = resultSet.getInt(COLUMN_VERSION);
-
- int valueOrderNum = resultSet.getInt(COLUMN_VORDERNUM);
- PersistedPropertyData prop = propertyBuffer.get(identifier);
-
- if (prop == null)
- {
- // make temporary PropertyData without values
- String cname = resultSet.getString(COLUMN_NAME);
-
- String cpid = resultSet.getString(COLUMN_PARENTID);
- int cptype = resultSet.getInt(COLUMN_PTYPE);
- boolean cpmultivalued = resultSet.getBoolean(COLUMN_PMULTIVALUED);
- QPath qpath = QPath.makeChildPath(traverseQPath(cpid), InternalQName.parse(cname));
-
- prop =
- new PersistedPropertyData(identifier, qpath, getIdentifier(cpid), cversion, cptype, cpmultivalued,
- null); // null values!
- propertyBuffer.put(identifier, prop);
- valuesBuffer.put(identifier, new ArrayList<ValueData>());
- dublicatedProps.put(identifier, new Integer(1));
- }
-
- List<ValueData> values = valuesBuffer.get(identifier);
- if (valueOrderNum == 0 && values.size() > 0)
- {
- // ignore it, this is a new copy
- Integer copies = dublicatedProps.get(identifier);
- copies++;
- dublicatedProps.put(identifier, copies);
- }
- else if (values.size() == valueOrderNum)
- {
- // read value and put into values buffer
- final String storageId = resultSet.getString(COLUMN_VSTORAGE_DESC);
- ValueData vdata =
- resultSet.wasNull() ? readValueData(cid, valueOrderNum, cversion, resultSet
- .getBinaryStream(COLUMN_VDATA)) : readValueData(identifier, valueOrderNum, storageId);
-
- values.add(vdata);
- valuesBuffer.put(identifier, values);
- }
- }
-
- for (String id : propertyBuffer.keySet())
- {
-
- PersistedPropertyData prop = propertyBuffer.get(id);
- List<ValueData> values = valuesBuffer.get(id);
- Collections.sort(values, COMPARATOR_VALUE_DATA);
- int count = dublicatedProps.get(id).intValue();
-
- for (int i = 0; i < count; i++)
- {
- //make a copy
- List<ValueData> newValues = new ArrayList<ValueData>();
- for (ValueData vd : values)
- {
- newValues.add(new ByteArrayPersistedValueData(vd.getOrderNumber(), vd.getAsByteArray()));
- }
-
- PersistedPropertyData pdata =
- new PersistedPropertyData(prop.getIdentifier(), prop.getQPath(), prop.getParentIdentifier(), prop
- .getPersistedVersion(), prop.getType(), prop.isMultiValued(), newValues);
- resultProps.add(pdata);
- }
- values.clear();
- }
- }
- catch (IllegalNameException e)
- {
- throw new RepositoryException(e);
- }
- finally
- {
- // clean buffers
- propertyBuffer.clear();
- valuesBuffer.clear();
- dublicatedProps.clear();
- }
-
- return resultProps;
- }
-
- /**
* Read ACL Permissions from properties set.
*
* @param cid node id (used only for error messages)
@@ -814,6 +662,4 @@
protected abstract ResultSet findChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException;
protected abstract ResultSet findNodeMainPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException;
-
- protected abstract ResultSet findReferencePropertiesCQ(String nodeIdentifier) throws SQLException;
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java 2010-03-19 15:20:47 UTC (rev 2086)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java 2010-03-19 17:45:28 UTC (rev 2087)
@@ -99,10 +99,6 @@
"select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX, I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED, V.ORDER_NUM,"
+ " V.DATA, V.STORAGE_DESC from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON (V.PROPERTY_ID=I.ID)"
+ " where I.PARENT_ID=? and I.I_CLASS=2 and I.CONTAINER_NAME=? order by I.NAME";
- FIND_REFERENCE_PROPERTIES_CQ =
- "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME, V.ORDER_NUM, V.DATA, V.STORAGE_DESC"
- + " from JCR_SREF R, JCR_SITEM P, JCR_SVALUE V"
- + " where R.NODE_ID=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2 and P.CONTAINER_NAME=? and V.PROPERTY_ID=P.ID order by R.PROPERTY_ID";
}
/**
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2010-03-19 15:20:47 UTC (rev 2086)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2010-03-19 17:45:28 UTC (rev 2087)
@@ -67,8 +67,6 @@
protected PreparedStatement findReferences;
- protected PreparedStatement findReferencePropertiesCQ;
-
protected PreparedStatement findValuesByPropertyId;
protected PreparedStatement findValuesDataByPropertyId;
@@ -188,11 +186,6 @@
"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_REFERENCE_PROPERTIES_CQ =
- "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME, V.ORDER_NUM, V.DATA, V.STORAGE_DESC"
- + " from JCR_MREF R, JCR_MITEM P, JCR_MVALUE V"
- + " where R.NODE_ID=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2 and V.PROPERTY_ID=P.ID order by R.PROPERTY_ID";
-
FIND_VALUES_BY_PROPERTYID =
"select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_MVALUE where PROPERTY_ID=? order by ORDER_NUM";
@@ -668,19 +661,4 @@
return findItemQPathByIdentifierCQ.executeQuery();
}
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findReferencePropertiesCQ(String nodeIdentifier) throws SQLException
- {
- if (findReferencePropertiesCQ == null)
- findReferencePropertiesCQ = dbConnection.prepareStatement(FIND_REFERENCE_PROPERTIES_CQ);
- else
- findReferencePropertiesCQ.clearParameters();
-
- findReferencePropertiesCQ.setString(1, nodeIdentifier);
- return findReferencePropertiesCQ.executeQuery();
- }
-
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleMultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleMultiDbJDBCConnection.java 2010-03-19 15:20:47 UTC (rev 2086)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleMultiDbJDBCConnection.java 2010-03-19 17:45:28 UTC (rev 2087)
@@ -70,13 +70,13 @@
super.prepareQueries();
FIND_NODES_BY_PARENTID_CQ =
- "select /*+ INDEX(I JCR_IDX_SITEM_PARENT_ID) INDEX(P JCR_IDX_SITEM_PARENT_ID) INDEX(V JCR_IDX_SVALUE_PROPERTY)*/ I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
+ "select /*+ INDEX(I JCR_IDX_MITEM_PARENT_ID) INDEX(P JCR_IDX_MITEM_PARENT_ID) INDEX(V JCR_IDX_MVALUE_PROPERTY)*/ I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
+ " from JCR_MITEM I, JCR_MITEM P, JCR_MVALUE V"
+ " where I.I_CLASS=1 and I.PARENT_ID=? and"
+ " P.I_CLASS=2 and P.PARENT_ID=I.ID and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')"
+ " and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID";
FIND_PROPERTIES_BY_PARENTID_CQ =
- "select /*+ INDEX(I JCR_IDX_SITEM_PARENT_ID) INDEX(V JCR_IDX_SVALUE_PROPERTY)*/ I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX, I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED,"
+ "select /*+ INDEX(I JCR_IDX_MITEM_PARENT_ID) INDEX(V JCR_IDX_MVALUE_PROPERTY)*/ I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX, I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED,"
+ " V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT OUTER JOIN JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)"
+ " where I.I_CLASS=2 and I.PARENT_ID=? order by I.NAME";
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2010-03-19 15:20:47 UTC (rev 2086)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2010-03-19 17:45:28 UTC (rev 2087)
@@ -65,8 +65,6 @@
protected PreparedStatement findReferences;
- protected PreparedStatement findReferencePropertiesCQ;
-
protected PreparedStatement findValuesByPropertyId;
protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
@@ -195,11 +193,6 @@
"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_REFERENCE_PROPERTIES_CQ =
- "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME, V.ORDER_NUM, V.DATA, V.STORAGE_DESC"
- + " from JCR_SREF R, JCR_SITEM P, JCR_SVALUE V"
- + " where R.NODE_ID=? and P.CONTAINER_NAME=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2 and V.PROPERTY_ID=P.ID order by R.PROPERTY_ID";
-
FIND_VALUES_BY_PROPERTYID =
"select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=? order by ORDER_NUM";
@@ -691,20 +684,4 @@
findItemQPathByIdentifierCQ.setString(1, identifier);
return findItemQPathByIdentifierCQ.executeQuery();
}
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findReferencePropertiesCQ(String nodeIdentifier) throws SQLException
- {
- if (findReferencePropertiesCQ == null)
- findReferencePropertiesCQ = dbConnection.prepareStatement(FIND_REFERENCE_PROPERTIES_CQ);
- else
- findReferencePropertiesCQ.clearParameters();
-
- findReferencePropertiesCQ.setString(1, nodeIdentifier);
- findReferencePropertiesCQ.setString(2, containerName);
- return findReferencePropertiesCQ.executeQuery();
- }
}
16 years, 1 month
exo-jcr SVN: r2086 - in core/trunk/exo.core.component.database/src: test/java/org/exoplatform/services/database and 1 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-03-19 11:20:47 -0400 (Fri, 19 Mar 2010)
New Revision: 2086
Added:
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBConnectionInfo.java
Modified:
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutor.java
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutorException.java
core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBScriptExecutor.java
core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml
Log:
EXOJCR-573: DBScriptExecutor small refactoring
Added: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBConnectionInfo.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBConnectionInfo.java (rev 0)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBConnectionInfo.java 2010-03-19 15:20:47 UTC (rev 2086)
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.database.creator;
+
+/**
+ * Class contains needed database connection information.
+ *
+ * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
+ * @version $Id: DBConnectionInfo.java 111 2010-11-11 11:11:11Z tolusha $
+ */
+public class DBConnectionInfo
+{
+ /**
+ * Driver class name.
+ */
+ private final String driver;
+
+ /**
+ * DB connection url;
+ */
+ private final String url;
+
+ /**
+ * DB connection user name;
+ */
+ private final String username;
+
+ /**
+ * User's password.
+ */
+ private final String password;
+
+ /**
+ * DBConnectionInfo constructor.
+ *
+ * @param driver
+ * driver class name
+ * @param url
+ * db connection url
+ * @param username
+ * db connection user name
+ * @param password
+ * user's password
+ */
+ public DBConnectionInfo(String driver, String url, String username, String password)
+ {
+ this.driver = driver;
+ this.url = url;
+ this.username = username;
+ this.password = password;
+ }
+
+ /**
+ * @return the driver
+ */
+ public String getDriver()
+ {
+ return driver;
+ }
+
+ /**
+ * @return the url
+ */
+ public String getUrl()
+ {
+ return url;
+ }
+
+ /**
+ * @return the username
+ */
+ public String getUsername()
+ {
+ return username;
+ }
+
+ /**
+ * @return the password
+ */
+ public String getPassword()
+ {
+ return password;
+ }
+
+}
Modified: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutor.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutor.java 2010-03-19 15:19:01 UTC (rev 2085)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutor.java 2010-03-19 15:20:47 UTC (rev 2086)
@@ -29,6 +29,8 @@
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
/**
* @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
@@ -58,27 +60,32 @@
protected final String driver;
/**
- * Database url.
+ * Server url.
*/
- protected final String url;
+ protected final String serverUrl;
/**
- * SA user name.
+ * User name with administrative rights for connection to server.
*/
- protected final String userName;
+ protected final String adminName;
/**
- * SA user's password.
+ * User's password.
*/
- protected final String password;
+ protected final String adminPwd;
/**
- * DB script creation.
+ * Internal login connection property needed for Oracle.
*/
+ protected final String internal_logon;
+
+ /**
+ * DDL script database creation.
+ */
protected final String dbScript;
/**
- * User name for new DB.
+ * User name for new database.
*/
protected final String dbUserName;
@@ -105,17 +112,37 @@
if (prop != null)
{
this.driver = prop.getProperty("driverClassName");
- this.url = prop.getProperty("url");
- this.userName = prop.getProperty("username");
- this.password = prop.getProperty("password");
+ if (driver == null)
+ {
+ throw new ConfigurationException("driverClassName expected in db-connection properties section");
+ }
+
+ this.serverUrl = prop.getProperty("url");
+ if (serverUrl == null)
+ {
+ throw new ConfigurationException("url expected in db-connection properties section");
+ }
+
+ this.adminName = prop.getProperty("username");
+ if (adminName == null)
+ {
+ throw new ConfigurationException("username expected in db-connection properties section");
+ }
+
+ this.adminPwd = prop.getProperty("password");
+ if (adminPwd == null)
+ {
+ throw new ConfigurationException("password expected in db-connection properties section");
+ }
+
+ this.internal_logon = prop.getProperty("internal_logon");
}
else
{
throw new ConfigurationException("db-connection properties expected in initializations parameters");
}
- prop = params.getPropertiesParam("script-execution");
-
+ prop = params.getPropertiesParam("db-creation");
if (prop != null)
{
String scriptPath = prop.getProperty("scriptPath");
@@ -132,75 +159,88 @@
}
else
{
- throw new ConfigurationException("scriptPath expected in initializations parameters");
+ throw new ConfigurationException("scriptPath expected in db-creation properties section");
}
this.dbUserName = prop.getProperty("username");
+ if (dbUserName == null)
+ {
+ throw new ConfigurationException("username expected in db-creation properties section");
+ }
+
this.dbPassword = prop.getProperty("password");
+ if (dbPassword == null)
+ {
+ throw new ConfigurationException("password expected in db-creation properties section");
+ }
}
else
{
- throw new ConfigurationException("db-creation properties expected in initializations parameters");
+ throw new ConfigurationException("db-creation properties expected in initializations parameters");
}
-
}
/**
* Execute DDL script for new database creation. Database name are passed as parameter,
- * user name and password are passed via configuration. In SQL script database name, user name
+ * user name and password are passed via configuration. In script database name, user name
* and password defined via templates as ${database}, ${username} and ${password} respectively.
+ * At execution time method replaces templates by real values.
*
* @param dbName
* new database name
* @throws DBScriptExecutorException
* if any error occurs
*/
- public void execute(String dbName) throws DBScriptExecutorException
+ public DBConnectionInfo createDatabase(String dbName) throws DBScriptExecutorException
{
Connection conn = null;
try
{
Class.forName(driver);
- conn = DriverManager.getConnection(url, userName, password);
+
+ Properties props = new java.util.Properties();
+ props.put("user", adminName);
+ props.put("password", adminPwd);
+ if (internal_logon != null)
+ {
+ props.put("internal_logon", internal_logon);
+ }
+ conn = DriverManager.getConnection(serverUrl, props);
}
catch (SQLException e)
{
- throw new DBScriptExecutorException("Can't establish the JDBC connection to database " + url, e);
+ throw new DBScriptExecutorException("Can't establish the JDBC connection to database " + serverUrl, e);
}
catch (ClassNotFoundException e)
{
throw new DBScriptExecutorException("Can't load the JDBC driver " + driver, e);
}
+ String dbProductName;
try
{
- conn.setAutoCommit(false);
+ dbProductName = conn.getMetaData().getDatabaseProductName();
- for (String scr : dbScript.split(";"))
+ if (dbProductName.startsWith("Microsoft SQL Server") || dbProductName.startsWith("Adaptive Server Anywhere")
+ || dbProductName.equals("Sybase SQL Server") || dbProductName.equals("Adaptive Server Enterprise"))
{
- scr = scr.replace(DATABASE_TEMPLATE, dbName);
- scr = scr.replace(USERNAME_TEMPLATE, dbUserName);
- scr = scr.replace(PASSWORD_TEMPLATE, dbPassword);
-
- String s = cleanWhitespaces(scr.trim());
- if (s.length() > 0)
- {
- conn.createStatement().executeUpdate(s);
- }
+ executeAutoCommitMode(conn, dbName);
}
- conn.commit();
+ else
+ {
+ executeBatchMode(conn, dbName);
+ }
}
catch (SQLException e)
{
- try
+ String errorTrace = "";
+ while (e != null)
{
- conn.rollback();
+ errorTrace += e.getMessage() + "; ";
+ e = e.getNextException();
}
- catch (SQLException e1)
- {
- throw new DBScriptExecutorException("Can't perform rollback", e1);
- }
- throw new DBScriptExecutorException("Can't execute SQL script", e);
+
+ throw new DBScriptExecutorException("Can't execute SQL script " + errorTrace);
}
finally
{
@@ -213,9 +253,83 @@
throw new DBScriptExecutorException("Can't close connection", e);
}
}
+
+ // try to solve database url connection depending on specific database
+ String dbUrl = serverUrl;
+ if (dbProductName.startsWith("Microsoft SQL Server"))
+ {
+ dbUrl = dbUrl + (dbUrl.endsWith(";") ? "" : ";") + "databaseName=" + dbName + ";";
+ }
+ else if (dbProductName.equals("Oracle"))
+ {
+ // do nothing
+ }
+ else
+ {
+ dbUrl = dbUrl + (dbUrl.endsWith("/") ? "" : "/") + dbName;
+ }
+
+ return new DBConnectionInfo(driver, dbUrl, dbUserName, dbPassword);
}
/**
+ * Executes DDL script in generic batch mode.
+ *
+ * @param conn
+ * connection to server
+ * @param dbName
+ * database name
+ * @throws SQLException
+ * if any errors occurs
+ */
+ private void executeBatchMode(Connection conn, String dbName) throws SQLException
+ {
+ Statement statement = conn.createStatement();
+ for (String scr : dbScript.split(";"))
+ {
+ scr = scr.replace(DATABASE_TEMPLATE, dbName);
+ scr = scr.replace(USERNAME_TEMPLATE, dbUserName);
+ scr = scr.replace(PASSWORD_TEMPLATE, dbPassword);
+
+ String s = cleanWhitespaces(scr.trim());
+ if (s.length() > 0)
+ {
+ statement.addBatch(s);
+ }
+ }
+ statement.executeBatch();
+ }
+
+ /**
+ * Executes DDL script with autocommit mode set true. Actually need for MSSQL and Sybase database servers.
+ * After execution "create database" command newly created database not available for "use" command and
+ * therefore you can't create user inside.
+ *
+ * @param conn
+ * connection to server
+ * @param dbName
+ * database name
+ * @throws SQLException
+ * if any errors occurs
+ */
+ private void executeAutoCommitMode(Connection conn, String dbName) throws SQLException
+ {
+ conn.setAutoCommit(true);
+ for (String scr : dbScript.split(";"))
+ {
+ scr = scr.replace(DATABASE_TEMPLATE, dbName);
+ scr = scr.replace(USERNAME_TEMPLATE, dbUserName);
+ scr = scr.replace(PASSWORD_TEMPLATE, dbPassword);
+
+ String s = cleanWhitespaces(scr.trim());
+ if (s.length() > 0)
+ {
+ conn.createStatement().executeUpdate(s);
+ }
+ }
+ }
+
+ /**
* Read SQL script from file resource.
*/
protected String readScriptResource(String path) throws IOException
Modified: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutorException.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutorException.java 2010-03-19 15:19:01 UTC (rev 2085)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutorException.java 2010-03-19 15:20:47 UTC (rev 2086)
@@ -40,4 +40,12 @@
{
super(message, e);
}
+
+ /**
+ * DBCreationException constructor.
+ */
+ public DBScriptExecutorException(String message)
+ {
+ super(message);
+ }
}
Modified: core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBScriptExecutor.java
===================================================================
--- core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBScriptExecutor.java 2010-03-19 15:19:01 UTC (rev 2085)
+++ core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBScriptExecutor.java 2010-03-19 15:20:47 UTC (rev 2086)
@@ -19,9 +19,17 @@
package org.exoplatform.services.database;
import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.database.creator.DBConnectionInfo;
import org.exoplatform.services.database.creator.DBScriptExecutor;
-import org.exoplatform.services.database.creator.DBScriptExecutorException;
+import org.exoplatform.services.naming.InitialContextBinder;
+import org.exoplatform.services.naming.InitialContextInitializer;
+import java.sql.Connection;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
import junit.framework.TestCase;
/**
@@ -31,24 +39,40 @@
public class TestDBScriptExecutor extends TestCase
{
- protected DBScriptExecutor dbCreator;
+ protected DBScriptExecutor dbExecutor;
+ private InitialContextBinder initialContextBinder;
+
+ private InitialContextInitializer initContext;
+
public void setUp() throws Exception
{
PortalContainer container = PortalContainer.getInstance();
- dbCreator = (DBScriptExecutor)container.getComponentInstanceOfType(DBScriptExecutor.class);
+
+ dbExecutor = (DBScriptExecutor)container.getComponentInstanceOfType(DBScriptExecutor.class);
+ initContext = (InitialContextInitializer)container.getComponentInstanceOfType(InitialContextInitializer.class);
+ initialContextBinder = (InitialContextBinder)container.getComponentInstanceOfType(InitialContextBinder.class);
}
- public void testExecute() throws Exception
+ public void testDBCreate() throws Exception
{
- assertNotNull(dbCreator);
- try
- {
- dbCreator.execute("testDB");
- }
- catch (DBScriptExecutorException e)
- {
- fail("Exception should not be thrown.");
- }
+ assertNotNull(dbExecutor);
+
+ DBConnectionInfo dbInfo = dbExecutor.createDatabase("testdb");
+
+ Map<String, String> refAddr = new HashMap<String, String>();
+ refAddr.put("driverClassName", dbInfo.getDriver());
+ refAddr.put("url", dbInfo.getUrl());
+ refAddr.put("username", dbInfo.getUsername());
+ refAddr.put("password", dbInfo.getPassword());
+
+ initialContextBinder.bind("testjdbcjcr", "javax.sql.DataSource",
+ "org.apache.commons.dbcp.BasicDataSourceFactory", null, refAddr);
+
+ DataSource ds = (DataSource)initContext.getInitialContext().lookup("testjdbcjcr");
+ assertNotNull(ds);
+
+ Connection conn = ds.getConnection();
+ assertNotNull(conn);
}
}
Modified: core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml 2010-03-19 15:19:01 UTC (rev 2085)
+++ core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml 2010-03-19 15:20:47 UTC (rev 2086)
@@ -51,28 +51,33 @@
</component>
<component>
- <key>org.exoplatform.services.database.creator.DBScriptExecutor</key>
- <type>org.exoplatform.services.database.creator.DBScriptExecutor</type>
- <init-params>
- <properties-param>
- <name>db-connection</name>
- <description>database connection properties</description>
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost/" />
- <property name="username" value="root" />
- <property name="password" value="admin" />
+ <key>org.exoplatform.services.database.creator.DBScriptExecutor</key>
+ <type>org.exoplatform.services.database.creator.DBScriptExecutor</type>
+ <init-params>
+ <properties-param>
+ <name>db-connection</name>
+ <description>database connection properties</description>
+ <property name="driverClassName" value="com.mysql.jdbc.Driver" />
+ <property name="url" value="jdbc:mysql://localhost/" />
+ <property name="username" value="root" />
+ <property name="password" value="admin" />
+ </properties-param>
+ <properties-param>
+ <name>db-creation</name>
+ <description>database creation properties</description>
+ <property name="scriptPath" value="script.sql" />
+ <property name="username" value="testuser" />
+ <property name="password" value="testpwd" />
</properties-param>
- <properties-param>
- <name>script-execution</name>
- <description>properites for new database creation</description>
- <property name="scriptPath" value="test.sql" />
- <property name="username" value="'user1'@'localhost'" />
- <property name="password" value="'pass1'" />
- </properties-param>
</init-params>
</component>
<component>
+ <key>org.exoplatform.services.naming.InitialContextBinder</key>
+ <type>org.exoplatform.services.naming.InitialContextBinder</type>
+ </component>
+
+ <component>
<key>org.exoplatform.services.naming.InitialContextInitializer</key>
<type>org.exoplatform.services.naming.InitialContextInitializer</type>
<component-plugins>
16 years, 1 month
exo-jcr SVN: r2085 - in kernel/trunk/exo.kernel.component.common/src: test/java/org/exoplatform/services/naming and 1 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-03-19 11:19:01 -0400 (Fri, 19 Mar 2010)
New Revision: 2085
Removed:
kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/naming/TestInitialContextBinder.java
Modified:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextBinder.java
kernel/trunk/exo.kernel.component.common/src/test/resources/conf/portal/test-configuration.xml
Log:
EXOJCR-573: InitContextBinder small refactoring
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextBinder.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextBinder.java 2010-03-19 07:22:38 UTC (rev 2084)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextBinder.java 2010-03-19 15:19:01 UTC (rev 2085)
@@ -19,9 +19,6 @@
package org.exoplatform.services.naming;
import org.exoplatform.container.configuration.ConfigurationException;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.container.xml.PropertiesParam;
-import org.exoplatform.container.xml.ValueParam;
import java.io.File;
import java.io.FileInputStream;
@@ -41,7 +38,6 @@
import javax.naming.RefAddr;
import javax.naming.Reference;
import javax.naming.StringRefAddr;
-import javax.sql.DataSource;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
@@ -54,6 +50,8 @@
import javax.xml.stream.events.XMLEvent;
/**
+ * Class is responsible for binding datasources at runtime, persists on file and automatically rebinds after restart.
+ *
* @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
* @version $Id: InitialContextBinder.java 111 2010-11-11 11:11:11Z tolusha $
*/
@@ -81,10 +79,8 @@
*/
protected final InitialContextInitializer initialContextInitializer;
- protected final String bindReferencesStorage;
+ protected final String bindReferencesPath;
- protected final Reference reference;
-
protected Map<String, Reference> bindReferences;
/**
@@ -100,41 +96,16 @@
* @throws XMLStreamException
* @throws NamingException
*/
- public InitialContextBinder(InitialContextInitializer initialContextInitializer, InitParams initParams)
- throws ConfigurationException, FileNotFoundException, XMLStreamException, NamingException
+ public InitialContextBinder(InitialContextInitializer initialContextInitializer) throws ConfigurationException,
+ FileNotFoundException, XMLStreamException, NamingException
{
this.initialContextInitializer = initialContextInitializer;
- ValueParam cnParam = initParams.getValueParam("class-name");
- if (cnParam == null)
- {
- throw new ConfigurationException("class-name parameter expected");
- }
+ this.bindReferences = new HashMap<String, Reference>();
+ this.bindReferencesPath = System.getProperty("java.io.tmpdir") + File.separator + "datasources.xml";
- ValueParam factoryParam = initParams.getValueParam("factory");
- if (factoryParam == null)
+ if (new File(bindReferencesPath).exists())
{
- throw new ConfigurationException("factory parameter expected");
- }
-
- ValueParam flParam = initParams.getValueParam("factory-location");
- String factoryLocation = flParam != null ? flParam.getValue() : null;
-
- this.reference = new Reference(cnParam.getValue(), factoryParam.getValue(), factoryLocation);
-
- PropertiesParam addrsParam = initParams.getPropertiesParam("ref-addresses");
- if (addrsParam != null)
- {
- for (Entry entry : addrsParam.getProperties().entrySet())
- {
- reference.add(new StringRefAddr((String)entry.getKey(), (String)entry.getValue()));
- }
- }
-
- this.bindReferencesStorage = System.getProperty("java.io.tmpdir") + File.separator + "datasources.xml";
- this.bindReferences = new HashMap<String, Reference>();
- if (new File(bindReferencesStorage).exists())
- {
this.bindReferences.putAll(doImport());
for (Entry<String, Reference> entry : bindReferences.entrySet())
{
@@ -144,24 +115,21 @@
}
/**
- * Bind reference and return datasource.
- *
- * @param bindName
- * bind name
- * @return datasource
- * @throws NamingException
- * @throws FileNotFoundException
- * @throws XMLStreamException
+ * Bind reference.
*/
- public DataSource bind(String bindName) throws NamingException, FileNotFoundException, XMLStreamException
+ public void bind(String bindName, String className, String factory, String factoryLocation,
+ Map<String, String> refAddr) throws NamingException, FileNotFoundException, XMLStreamException
{
+ Reference reference = new Reference(className, factory, factoryLocation);
+ for (Entry entry : refAddr.entrySet())
+ {
+ reference.add(new StringRefAddr((String)entry.getKey(), (String)entry.getValue()));
+ }
+
bind(bindName, reference);
bindReferences.put(bindName, reference);
doExport();
-
- return (DataSource)initialContextInitializer.getInitialContext().lookup(bindName);
-
}
private void bind(String bindName, Reference reference) throws NamingException
@@ -170,7 +138,7 @@
}
/**
- * Export into xml.
+ * Export references into xml-file.
*
* @throws XMLStreamException
* @throws FileNotFoundException
@@ -178,8 +146,7 @@
protected void doExport() throws XMLStreamException, FileNotFoundException
{
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
- XMLStreamWriter writer =
- outputFactory.createXMLStreamWriter(new FileOutputStream(bindReferencesStorage), "UTF-8");
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(new FileOutputStream(bindReferencesPath), "UTF-8");
writer.writeStartDocument("UTF-8", "1.0");
writer.writeStartElement(BIND_REFERENCES_ELEMENT);
@@ -220,9 +187,10 @@
}
/**
- * Import from xml.
+ * Import references from xml-file.
*
- * @return
+ * @return list of references
+ *
* @throws XMLStreamException
* @throws FileNotFoundException
*/
@@ -231,7 +199,7 @@
Map<String, Reference> references = new HashMap<String, Reference>();
XMLInputFactory factory = XMLInputFactory.newInstance();
- XMLEventReader reader = factory.createXMLEventReader(new FileInputStream(bindReferencesStorage), "UTF-8");
+ XMLEventReader reader = factory.createXMLEventReader(new FileInputStream(bindReferencesPath), "UTF-8");
while (reader.hasNext())
{
Deleted: kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/naming/TestInitialContextBinder.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/naming/TestInitialContextBinder.java 2010-03-19 07:22:38 UTC (rev 2084)
+++ kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/naming/TestInitialContextBinder.java 2010-03-19 15:19:01 UTC (rev 2085)
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.naming;
-
-import org.exoplatform.container.PortalContainer;
-
-import junit.framework.TestCase;
-
-import javax.sql.DataSource;
-
-/**
- * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
- * @version $Id: TestInitialContextBinder.java 111 2010-11-11 11:11:11Z tolusha $
- */
-public class TestInitialContextBinder extends TestCase
-{
- private InitialContextBinder initialContextBinder;
-
- public void setUp() throws Exception
- {
- PortalContainer container = PortalContainer.getInstance();
-
- InitialContextInitializer initializer =
- (InitialContextInitializer)container.getComponentInstanceOfType(InitialContextInitializer.class);
- initialContextBinder = (InitialContextBinder)container.getComponentInstanceOfType(InitialContextBinder.class);
- }
-
- public void testBind() throws Exception
- {
- DataSource ds = initialContextBinder.bind("testjdbcjcr");
- assertNotNull(ds);
- }
-
-}
Modified: kernel/trunk/exo.kernel.component.common/src/test/resources/conf/portal/test-configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/test/resources/conf/portal/test-configuration.xml 2010-03-19 07:22:38 UTC (rev 2084)
+++ kernel/trunk/exo.kernel.component.common/src/test/resources/conf/portal/test-configuration.xml 2010-03-19 15:19:01 UTC (rev 2085)
@@ -48,24 +48,6 @@
<component>
<key>org.exoplatform.services.naming.InitialContextBinder</key>
<type>org.exoplatform.services.naming.InitialContextBinder</type>
- <init-params>
- <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>
16 years, 1 month
exo-jcr SVN: r2084 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc: optimisation and 1 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-03-19 03:22:38 -0400 (Fri, 19 Mar 2010)
New Revision: 2084
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleMultiDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleSingleDbJDBCConnection.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
Log:
EXOJCR-519: Perfs have been improved on HSQLDB, MySQL and Oracle.
For HSQLDB: The filters of the complex queries were not on the right order
for MySQL: The complex traverseQPath method has been re-added since we get much better performances with this method than with the old one, this method is only slower with HSQLDB so only HSQLDB uses the old one.
for Oracle: Hints have been added to complex queries to prevent oracle to use the bad execution plan
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2010-03-18 14:17:20 UTC (rev 2083)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2010-03-19 07:22:38 UTC (rev 2084)
@@ -946,6 +946,16 @@
*/
protected QPath traverseQPath(String cpid) throws SQLException, InvalidItemStateException, IllegalNameException
{
+ return traverseQPathSQ(cpid);
+ }
+
+ /**
+ * The method <code>traverseQPath</code> implemented thanks to simple queries. It allows
+ * to use Simple Queries instead of Complex Queries when complex queries are much slower such
+ * as with HSQLDB for example.
+ */
+ protected QPath traverseQPathSQ(String cpid) throws SQLException, InvalidItemStateException, IllegalNameException
+ {
// get item by Identifier usecase
List<QPathEntry> qrpath = new ArrayList<QPathEntry>(); // reverted path
String caid = cpid; // container ancestor id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2010-03-18 14:17:20 UTC (rev 2083)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2010-03-19 07:22:38 UTC (rev 2084)
@@ -28,6 +28,7 @@
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.dataflow.persistent.ByteArrayPersistedValueData;
@@ -54,6 +55,7 @@
import java.util.StringTokenizer;
import java.util.TreeSet;
+import javax.jcr.InvalidItemStateException;
import javax.jcr.RepositoryException;
/**
@@ -91,6 +93,11 @@
protected String FIND_REFERENCE_PROPERTIES_CQ;
/**
+ * FIND_ITEM_QPATH_BY_ID_CQ.
+ */
+ protected String FIND_ITEM_QPATH_BY_ID_CQ;
+
+ /**
* The comparator used to sort the value data
*/
private static Comparator<ValueData> COMPARATOR_VALUE_DATA = new Comparator<ValueData>()
@@ -724,6 +731,84 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected QPath traverseQPath(String cpid) throws SQLException, InvalidItemStateException, IllegalNameException
+ {
+ String id = getIdentifier(cpid);
+ if (id.equals(Constants.ROOT_UUID))
+ {
+ return Constants.ROOT_PATH;
+ }
+ // get item by Identifier usecase
+ List<QPathEntry> qrpath = new ArrayList<QPathEntry>(); // reverted path
+ String caid = cpid; // container ancestor id
+ boolean isRoot = false;
+ do
+ {
+ ResultSet result = null;
+ try
+ {
+ result = findItemQPathByIdentifierCQ(caid);
+ if (!result.next())
+ throw new InvalidItemStateException("Parent not found, uuid: " + getIdentifier(caid));
+
+ QPathEntry qpe1 =
+ new QPathEntry(InternalQName.parse(result.getString(COLUMN_NAME)), result.getInt(COLUMN_INDEX));
+ boolean isChild = caid.equals(result.getString(COLUMN_ID));
+ caid = result.getString(COLUMN_PARENTID);
+ if (result.next())
+ {
+ QPathEntry qpe2 =
+ new QPathEntry(InternalQName.parse(result.getString(COLUMN_NAME)), result.getInt(COLUMN_INDEX));
+ if (isChild)
+ {
+ // The child is the first result then we have the parent
+ qrpath.add(qpe1);
+ qrpath.add(qpe2);
+ // We need to take the value of the parent node
+ caid = result.getString(COLUMN_PARENTID);
+ }
+ else
+ {
+ // The parent is the first result then we have the child
+ qrpath.add(qpe2);
+ qrpath.add(qpe1);
+ }
+ }
+ else
+ {
+ qrpath.add(qpe1);
+ }
+ }
+ finally
+ {
+ result.close();
+ }
+ if (caid.equals(Constants.ROOT_PARENT_UUID) || (id = getIdentifier(caid)).equals(Constants.ROOT_UUID))
+ {
+ if (id.equals(Constants.ROOT_UUID))
+ {
+ qrpath.add(Constants.ROOT_PATH.getEntries()[0]);
+ }
+ isRoot = true;
+ }
+ }
+ while (!isRoot);
+
+ QPathEntry[] qentries = new QPathEntry[qrpath.size()];
+ int qi = 0;
+ for (int i = qrpath.size() - 1; i >= 0; i--)
+ {
+ qentries[qi++] = qrpath.get(i);
+ }
+ return new QPath(qentries);
+ }
+
+ protected abstract ResultSet findItemQPathByIdentifierCQ(String identifier) throws SQLException;
+
protected abstract ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier) throws SQLException;
protected abstract ResultSet findChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java 2010-03-18 14:17:20 UTC (rev 2083)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java 2010-03-19 07:22:38 UTC (rev 2084)
@@ -24,13 +24,14 @@
import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.GenericConnectionFactory;
-import org.exoplatform.services.jcr.impl.storage.jdbc.init.StorageDBInitializer;
import org.exoplatform.services.jcr.impl.storage.jdbc.init.IngresSQLDBInitializer;
import org.exoplatform.services.jcr.impl.storage.jdbc.init.OracleDBInitializer;
import org.exoplatform.services.jcr.impl.storage.jdbc.init.PgSQLDBInitializer;
+import org.exoplatform.services.jcr.impl.storage.jdbc.init.StorageDBInitializer;
import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.GenericCQConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.HSQLDBConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.MySQLConnectionFactory;
+import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.DefaultOracleConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.OracleConnectionFactory;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerException;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
@@ -92,7 +93,15 @@
LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is experimental!");
// sample of connection factory customization
if (dbSourceName != null)
- this.connFactory = defaultConnectionFactory();
+ {
+ DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
+ if (ds != null)
+ this.connFactory =
+ new DefaultOracleConnectionFactory(ds, containerName, multiDb, valueStorageProvider, maxBufferSize,
+ swapDirectory, swapCleaner);
+ else
+ throw new RepositoryException("Datasource '" + dbSourceName + "' is not bound in this context.");
+ }
else
this.connFactory =
new OracleConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
@@ -106,7 +115,20 @@
else if (dbDialect == DBConstants.DB_DIALECT_ORACLE)
{
- this.connFactory = defaultConnectionFactory();
+ if (dbSourceName != null)
+ {
+ DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
+ if (ds != null)
+ this.connFactory =
+ new DefaultOracleConnectionFactory(ds, containerName, multiDb, valueStorageProvider, maxBufferSize,
+ swapDirectory, swapCleaner);
+ else
+ throw new RepositoryException("Datasource '" + dbSourceName + "' is not bound in this context.");
+ }
+ else
+ this.connFactory =
+ new DefaultOracleConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ora.sql";
dbInitilizer = new OracleDBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java 2010-03-19 07:22:38 UTC (rev 2084)
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
+
+import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+
+import java.io.File;
+import java.sql.SQLException;
+
+import javax.jcr.RepositoryException;
+import javax.sql.DataSource;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 19 mars 2010
+ */
+public class DefaultOracleConnectionFactory extends GenericCQConnectionFactory
+{
+ /**
+ * DefaultOracleConnectionFactory constructor.
+ *
+ * @param dataSource
+ * - DataSource
+ * @param containerName
+ * - Container name (see configuration)
+ * @param multiDb
+ * - multidatabase state flag
+ * @param valueStorageProvider
+ * - external Value Storages provider
+ * @param maxBufferSize
+ * - Maximum buffer size (see configuration)
+ * @param swapDirectory
+ * - Swap directory (see configuration)
+ * @param swapCleaner
+ * - Swap cleaner (internal FileCleaner).
+ */
+ public DefaultOracleConnectionFactory(DataSource dataSource, String containerName, boolean multiDb,
+ ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
+ {
+
+ super(dataSource, containerName, multiDb, valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ }
+
+ /**
+ * DefaultOracleConnectionFactory constructor.
+ *
+ *@param dataSource
+ * - DataSource
+ * @param dbDriver
+ * - JDBC Driver
+ * @param dbUrl
+ * - JDBC URL
+ * @param dbUserName
+ * - database username
+ * @param dbPassword
+ * - database user password
+ * @param containerName
+ * - Container name (see configuration)
+ * @param multiDb
+ * - multidatabase state flag
+ * @param valueStorageProvider
+ * - external Value Storages provider
+ * @param maxBufferSize
+ * - Maximum buffer size (see configuration)
+ * @param swapDirectory
+ * - Swap directory (see configuration)
+ * @param swapCleaner
+ * - Swap cleaner (internal FileCleaner).
+ * @throws RepositoryException
+ * if error eccurs
+ */
+ public DefaultOracleConnectionFactory(String dbDriver, String dbUrl, String dbUserName, String dbPassword,
+ String containerName, boolean multiDb, ValueStoragePluginProvider valueStorageProvider, int maxBufferSize,
+ File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ {
+
+ super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb, valueStorageProvider, maxBufferSize,
+ swapDirectory, swapCleaner);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public WorkspaceStorageConnection openConnection(boolean readOnly) throws RepositoryException
+ {
+ try
+ {
+
+ if (multiDb)
+ {
+ return new OracleMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly, containerName,
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ }
+
+ return new OracleSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly, containerName,
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java 2010-03-18 14:17:20 UTC (rev 2083)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java 2010-03-19 07:22:38 UTC (rev 2084)
@@ -16,6 +16,8 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
+import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
@@ -23,6 +25,8 @@
import java.sql.Connection;
import java.sql.SQLException;
+import javax.jcr.InvalidItemStateException;
+
/**
* Created by The eXo Platform SAS
*
@@ -76,5 +80,23 @@
FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where PARENT_ID=? and I_CLASS=1" + " order by N_ORDER_NUM";
FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + " where PARENT_ID=? and I_CLASS=1";
FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where PARENT_ID=? and I_CLASS=2" + " order by ID";
+ FIND_NODES_BY_PARENTID_CQ =
+ "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
+ + " from JCR_MITEM I, JCR_MITEM P, JCR_MVALUE V"
+ + " where I.PARENT_ID=? and I.I_CLASS=1 and (P.PARENT_ID=I.ID and P.I_CLASS=2 and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and V.PROPERTY_ID=P.ID)"
+ + " order by I.N_ORDER_NUM, I.ID";
+ FIND_PROPERTIES_BY_PARENTID_CQ =
+ "select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX, I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED,"
+ + " V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT OUTER JOIN JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)"
+ + " where I.PARENT_ID=? and I.I_CLASS=2 order by I.NAME";
}
+
+ /**
+ * Use simple queries since it is much faster
+ */
+ @Override
+ protected QPath traverseQPath(String cpid) throws SQLException, InvalidItemStateException, IllegalNameException
+ {
+ return traverseQPathSQ(cpid);
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java 2010-03-18 14:17:20 UTC (rev 2083)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java 2010-03-19 07:22:38 UTC (rev 2084)
@@ -16,6 +16,8 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
+import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
@@ -24,6 +26,8 @@
import java.sql.ResultSet;
import java.sql.SQLException;
+import javax.jcr.InvalidItemStateException;
+
/**
* Created by The eXo Platform SAS
*
@@ -85,9 +89,32 @@
"select count(ID) from JCR_SITEM" + " where PARENT_ID=? and I_CLASS=1 and CONTAINER_NAME=?";
FIND_PROPERTIES_BY_PARENTID =
"select * from JCR_SITEM" + " where PARENT_ID=? and I_CLASS=2 and CONTAINER_NAME=?" + " order by ID";
+ FIND_NODES_BY_PARENTID_CQ =
+ "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
+ + " from JCR_SITEM I, JCR_SITEM P, JCR_SVALUE V"
+ + " where I.PARENT_ID=? and I.I_CLASS=1 and I.CONTAINER_NAME=? and"
+ + " P.PARENT_ID=I.ID and P.I_CLASS=2 and P.CONTAINER_NAME=? and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')"
+ + " and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID";
+ FIND_PROPERTIES_BY_PARENTID_CQ =
+ "select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX, I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED, V.ORDER_NUM,"
+ + " V.DATA, V.STORAGE_DESC from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON (V.PROPERTY_ID=I.ID)"
+ + " where I.PARENT_ID=? and I.I_CLASS=2 and I.CONTAINER_NAME=? order by I.NAME";
+ FIND_REFERENCE_PROPERTIES_CQ =
+ "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME, V.ORDER_NUM, V.DATA, V.STORAGE_DESC"
+ + " from JCR_SREF R, JCR_SITEM P, JCR_SVALUE V"
+ + " where R.NODE_ID=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2 and P.CONTAINER_NAME=? and V.PROPERTY_ID=P.ID order by R.PROPERTY_ID";
}
/**
+ * Use simple queries since it is much faster
+ */
+ @Override
+ protected QPath traverseQPath(String cpid) throws SQLException, InvalidItemStateException, IllegalNameException
+ {
+ return traverseQPathSQ(cpid);
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -169,4 +196,39 @@
findPropertiesByParentId.setString(2, containerName);
return findPropertiesByParentId.executeQuery();
}
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier) throws SQLException
+ {
+ if (findNodesByParentIdCQ == null)
+ findNodesByParentIdCQ = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID_CQ);
+ else
+ findNodesByParentIdCQ.clearParameters();
+
+ findNodesByParentIdCQ.setString(1, parentIdentifier);
+ findNodesByParentIdCQ.setString(2, containerName);
+ findNodesByParentIdCQ.setString(3, containerName);
+ return findNodesByParentIdCQ.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
+ {
+ if (findPropertiesByParentIdCQ == null)
+ findPropertiesByParentIdCQ = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID_CQ);
+ else
+ findPropertiesByParentIdCQ.clearParameters();
+
+ findPropertiesByParentIdCQ.setString(1, parentIdentifier);
+ findPropertiesByParentIdCQ.setString(2, containerName);
+ return findPropertiesByParentIdCQ.executeQuery();
+
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2010-03-18 14:17:20 UTC (rev 2083)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2010-03-19 07:22:38 UTC (rev 2084)
@@ -215,6 +215,11 @@
+ " from JCR_MITEM I, JCR_MVALUE V"
+ " where I.I_CLASS=2 and I.PARENT_ID=? and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and I.ID=V.PROPERTY_ID";
+ FIND_ITEM_QPATH_BY_ID_CQ =
+ "select I.ID, I.PARENT_ID, I.NAME, I.I_INDEX"
+ + " from JCR_MITEM I, (SELECT ID, PARENT_ID from JCR_MITEM where ID=?) J"
+ + " where I.ID = J.ID or I.ID = J.PARENT_ID";
+
FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?";
FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=2 and PARENT_ID=?" + " order by NAME";
@@ -652,6 +657,21 @@
* {@inheritDoc}
*/
@Override
+ protected ResultSet findItemQPathByIdentifierCQ(String identifier) throws SQLException
+ {
+ if (findItemQPathByIdentifierCQ == null)
+ findItemQPathByIdentifierCQ = dbConnection.prepareStatement(FIND_ITEM_QPATH_BY_ID_CQ);
+ else
+ findItemQPathByIdentifierCQ.clearParameters();
+
+ findItemQPathByIdentifierCQ.setString(1, identifier);
+ return findItemQPathByIdentifierCQ.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
protected ResultSet findReferencePropertiesCQ(String nodeIdentifier) throws SQLException
{
if (findReferencePropertiesCQ == null)
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java 2010-03-18 14:17:20 UTC (rev 2083)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java 2010-03-19 07:22:38 UTC (rev 2084)
@@ -41,7 +41,7 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
* @version $Id$
*/
-public class OracleConnectionFactory extends GenericCQConnectionFactory
+public class OracleConnectionFactory extends DefaultOracleConnectionFactory
{
public static int CONNCACHE_MAX_LIMIT = 25;
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleMultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleMultiDbJDBCConnection.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleMultiDbJDBCConnection.java 2010-03-19 07:22:38 UTC (rev 2084)
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
+
+import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 19 mars 2010
+ */
+public class OracleMultiDbJDBCConnection extends MultiDbJDBCConnection
+{
+
+ /**
+ * Oracle Multidatabase JDBC Connection constructor.
+ *
+ * @param dbConnection
+ * JDBC connection, shoudl be opened before
+ * @param readOnly
+ * boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerName
+ * Workspace Storage Container name (see configuration)
+ * @param valueStorageProvider
+ * External Value Storages provider
+ * @param maxBufferSize
+ * Maximum buffer size (see configuration)
+ * @param swapDirectory
+ * Swap directory File (see configuration)
+ * @param swapCleaner
+ * Swap cleaner (internal FileCleaner).
+ * @throws SQLException
+ *
+ * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ */
+ public OracleMultiDbJDBCConnection(Connection dbConnection, boolean readOnly, String containerName,
+ ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
+ throws SQLException
+ {
+
+ super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void prepareQueries() throws SQLException
+ {
+
+ super.prepareQueries();
+ FIND_NODES_BY_PARENTID_CQ =
+ "select /*+ INDEX(I JCR_IDX_SITEM_PARENT_ID) INDEX(P JCR_IDX_SITEM_PARENT_ID) INDEX(V JCR_IDX_SVALUE_PROPERTY)*/ I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
+ + " from JCR_MITEM I, JCR_MITEM P, JCR_MVALUE V"
+ + " where I.I_CLASS=1 and I.PARENT_ID=? and"
+ + " P.I_CLASS=2 and P.PARENT_ID=I.ID and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')"
+ + " and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID";
+ FIND_PROPERTIES_BY_PARENTID_CQ =
+ "select /*+ INDEX(I JCR_IDX_SITEM_PARENT_ID) INDEX(V JCR_IDX_SVALUE_PROPERTY)*/ I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX, I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED,"
+ + " V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT OUTER JOIN JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)"
+ + " where I.I_CLASS=2 and I.PARENT_ID=? order by I.NAME";
+ }
+}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleSingleDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleSingleDbJDBCConnection.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleSingleDbJDBCConnection.java 2010-03-19 07:22:38 UTC (rev 2084)
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
+
+import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 19 mars 2010
+ */
+public class OracleSingleDbJDBCConnection extends SingleDbJDBCConnection
+{
+
+ /**
+ * Oracle Singledatabase JDBC Connection constructor.
+ *
+ * @param dbConnection
+ * JDBC connection, should be opened before
+ * @param readOnly
+ * boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerName
+ * Workspace Storage Container name (see configuration)
+ * @param valueStorageProvider
+ * External Value Storages provider
+ * @param maxBufferSize
+ * Maximum buffer size (see configuration)
+ * @param swapDirectory
+ * Swap directory File (see configuration)
+ * @param swapCleaner
+ * Swap cleaner (internal FileCleaner).
+ * @throws SQLException
+ *
+ * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ */
+ public OracleSingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String containerName,
+ ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
+ throws SQLException
+ {
+
+ super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void prepareQueries() throws SQLException
+ {
+
+ super.prepareQueries();
+ FIND_NODES_BY_PARENTID_CQ =
+ "select /*+ INDEX(I JCR_IDX_SITEM_PARENT_ID) INDEX(P JCR_IDX_SITEM_PARENT_ID) INDEX(V JCR_IDX_SVALUE_PROPERTY)*/ I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
+ + " from JCR_SITEM I, JCR_SITEM P, JCR_SVALUE V"
+ + " where I.I_CLASS=1 and I.CONTAINER_NAME=? and I.PARENT_ID=? and"
+ + " P.I_CLASS=2 and P.CONTAINER_NAME=? and P.PARENT_ID=I.ID and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')"
+ + " and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID";
+ FIND_PROPERTIES_BY_PARENTID_CQ =
+ "select /*+ INDEX(I JCR_IDX_SITEM_PARENT_ID) INDEX(V JCR_IDX_SVALUE_PROPERTY)*/ I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX, I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED, V.ORDER_NUM,"
+ + " V.DATA, V.STORAGE_DESC from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON (V.PROPERTY_ID=I.ID)"
+ + " where I.I_CLASS=2 and I.CONTAINER_NAME=? and I.PARENT_ID=? order by I.NAME";
+ }
+}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2010-03-18 14:17:20 UTC (rev 2083)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2010-03-19 07:22:38 UTC (rev 2084)
@@ -223,6 +223,11 @@
+ " from JCR_SITEM I, JCR_SVALUE V"
+ " where I.I_CLASS=2 and I.CONTAINER_NAME=? and I.PARENT_ID=? and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and I.ID=V.PROPERTY_ID";
+ FIND_ITEM_QPATH_BY_ID_CQ =
+ "select I.ID, I.PARENT_ID, I.NAME, I.I_INDEX"
+ + " from JCR_SITEM I, (SELECT ID, PARENT_ID from JCR_SITEM where ID=?) J"
+ + " where I.ID = J.ID or I.ID = J.PARENT_ID";
+
FIND_NODES_COUNT_BY_PARENTID =
"select count(ID) from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
@@ -676,6 +681,21 @@
* {@inheritDoc}
*/
@Override
+ protected ResultSet findItemQPathByIdentifierCQ(String identifier) throws SQLException
+ {
+ if (findItemQPathByIdentifierCQ == null)
+ findItemQPathByIdentifierCQ = dbConnection.prepareStatement(FIND_ITEM_QPATH_BY_ID_CQ);
+ else
+ findItemQPathByIdentifierCQ.clearParameters();
+
+ findItemQPathByIdentifierCQ.setString(1, identifier);
+ return findItemQPathByIdentifierCQ.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
protected ResultSet findReferencePropertiesCQ(String nodeIdentifier) throws SQLException
{
if (findReferencePropertiesCQ == null)
16 years, 1 month
exo-jcr SVN: r2083 - jcr/trunk/exo.jcr.component.core.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-03-18 10:17:20 -0400 (Thu, 18 Mar 2010)
New Revision: 2083
Modified:
jcr/trunk/exo.jcr.component.core/pom.xml
Log:
EXOJCR-590 build profiles updated
Modified: jcr/trunk/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/pom.xml 2010-03-18 13:57:03 UTC (rev 2082)
+++ jcr/trunk/exo.jcr.component.core/pom.xml 2010-03-18 14:17:20 UTC (rev 2083)
@@ -668,6 +668,7 @@
<exclude>org/exoplatform/services/jcr/**/impl/**/TestSessionDataManager.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/TestLinkedWorkspaceStorageCacheMetrics.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/SQLBenchmarkTest.java</exclude>
+ <exclude>org/exoplatform/services/jcr/**/impl/**/TestCleanableFileStreamValueData.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/TestLockPerstistentDataManager.java</exclude>
<exclude>org/exoplatform/services/jcr/**/api/**/TestOrderBefore.java</exclude>
<!-- From TCK -->
@@ -708,6 +709,7 @@
<include>**/**/reading_/Test*.java</include>
<include>**/**/writing_/Test*.java</include>
<include>**/**/TestJBossCacheWorkspaceStorageCache_.java</include>
+ <exclude>**/**/TestCleanableFileStreamValueData.java</exclude>
<include>**/**/TestSVNodeDataOptimization_.java</include>
<include>**/**/TestValueConstraints.java</include>
</includes>
16 years, 1 month
exo-jcr SVN: r2082 - in jcr/trunk: exo.jcr.component.core and 1 other directories.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-03-18 09:57:03 -0400 (Thu, 18 Mar 2010)
New Revision: 2082
Modified:
jcr/trunk/exo.jcr.component.core/pom.xml
jcr/trunk/exo.jcr.framework.ftpclient/pom.xml
jcr/trunk/pom.xml
Log:
EXOJCR-590 tests are excluded in their project's pom's
Modified: jcr/trunk/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/pom.xml 2010-03-18 11:12:01 UTC (rev 2081)
+++ jcr/trunk/exo.jcr.component.core/pom.xml 2010-03-18 13:57:03 UTC (rev 2082)
@@ -398,6 +398,7 @@
<exclude>org/exoplatform/services/jcr/**/impl/**/TestLinkedWorkspaceStorageCacheMetrics.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/SQLBenchmarkTest.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/TestLockPerstistentDataManager.java</exclude>
+ <exclude>org/exoplatform/services/jcr/**/impl/**/TestCleanableFileStreamValueData.java</exclude>
<exclude>org/exoplatform/services/jcr/**/api/**/TestOrderBefore.java</exclude>
</excludes>
</configuration>
Modified: jcr/trunk/exo.jcr.framework.ftpclient/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.framework.ftpclient/pom.xml 2010-03-18 11:12:01 UTC (rev 2081)
+++ jcr/trunk/exo.jcr.framework.ftpclient/pom.xml 2010-03-18 13:57:03 UTC (rev 2082)
@@ -52,7 +52,14 @@
</archive>
</configuration>
</plugin>
- </plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
</pluginManagement>
</build>
</project>
Modified: jcr/trunk/pom.xml
===================================================================
--- jcr/trunk/pom.xml 2010-03-18 11:12:01 UTC (rev 2081)
+++ jcr/trunk/pom.xml 2010-03-18 13:57:03 UTC (rev 2082)
@@ -419,20 +419,6 @@
</includes>
</testResource>
</testResources>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>**/ftpclient/**/*.java</exclude>
- <exclude>**/TestCleanableFileStreamValueData.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
</build>
<modules>
<module>exo.jcr.component.core</module>
16 years, 1 month
exo-jcr SVN: r2081 - in core/trunk: exo.core.component.database and 1 other directories.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-03-18 07:12:01 -0400 (Thu, 18 Mar 2010)
New Revision: 2081
Modified:
core/trunk/exo.core.component.database/pom.xml
core/trunk/exo.core.component.organization.jdbc/pom.xml
core/trunk/pom.xml
Log:
EXOJCR-590 tests are now excluded in their projects, not in parent pom
Modified: core/trunk/exo.core.component.database/pom.xml
===================================================================
--- core/trunk/exo.core.component.database/pom.xml 2010-03-17 10:54:38 UTC (rev 2080)
+++ core/trunk/exo.core.component.database/pom.xml 2010-03-18 11:12:01 UTC (rev 2081)
@@ -113,6 +113,7 @@
<configuration>
<excludes>
<exclude>**/DBCreatorTest.java</exclude>
+ <exclude>**/TestDBScriptExecutor.java</exclude>
</excludes>
</configuration>
</plugin>
Modified: core/trunk/exo.core.component.organization.jdbc/pom.xml
===================================================================
--- core/trunk/exo.core.component.organization.jdbc/pom.xml 2010-03-17 10:54:38 UTC (rev 2080)
+++ core/trunk/exo.core.component.organization.jdbc/pom.xml 2010-03-18 11:12:01 UTC (rev 2081)
@@ -110,4 +110,18 @@
<scope>test</scope>
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/TestOrganizationService.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ </build>
</project>
\ No newline at end of file
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2010-03-17 10:54:38 UTC (rev 2080)
+++ core/trunk/pom.xml 2010-03-18 11:12:01 UTC (rev 2081)
@@ -349,28 +349,4 @@
<scope>test</scope>
</dependency>
</dependencies>
-
- <build>
- <plugins>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <forkMode>always</forkMode>
- <excludes>
- <exclude>**/*$*</exclude>
- <exclude>**/DBCreatorTest.java</exclude>
- <exclude>**/TestDBScriptExecutor.java</exclude>
- <exclude>**/TestLDAPService.java</exclude>
- <exclude>**/TestNovellLDAPAPI.java</exclude>
- <exclude>**/TestStandardLDAPAPI.java</exclude>
- <!-- commented to avoid fail tests LDAP organization service -->
- <exclude>**/TestOrganizationService.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
-
- </build>
</project>
16 years, 1 month
exo-jcr SVN: r2080 - in core/trunk/exo.core.component.database/src: test/resources/conf/standalone and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-03-17 06:54:38 -0400 (Wed, 17 Mar 2010)
New Revision: 2080
Modified:
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutor.java
core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml
Log:
EXOJCR-574: rename properties section
Modified: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutor.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutor.java 2010-03-17 07:57:04 UTC (rev 2079)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutor.java 2010-03-17 10:54:38 UTC (rev 2080)
@@ -114,7 +114,7 @@
throw new ConfigurationException("db-connection properties expected in initializations parameters");
}
- prop = params.getPropertiesParam("db-creation");
+ prop = params.getPropertiesParam("script-execution");
if (prop != null)
{
Modified: core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml 2010-03-17 07:57:04 UTC (rev 2079)
+++ core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml 2010-03-17 10:54:38 UTC (rev 2080)
@@ -57,17 +57,17 @@
<properties-param>
<name>db-connection</name>
<description>database connection properties</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="" />
+ <property name="driverClassName" value="com.mysql.jdbc.Driver" />
+ <property name="url" value="jdbc:mysql://localhost/" />
+ <property name="username" value="root" />
+ <property name="password" value="admin" />
</properties-param>
<properties-param>
- <name>db-creation</name>
+ <name>script-execution</name>
<description>properites for new database creation</description>
<property name="scriptPath" value="test.sql" />
- <property name="username" value="sa" />
- <property name="password" value="" />
+ <property name="username" value="'user1'@'localhost'" />
+ <property name="password" value="'pass1'" />
</properties-param>
</init-params>
</component>
16 years, 1 month
exo-jcr SVN: r2079 - jcr/trunk/exo.jcr.component.core.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2010-03-17 03:57:04 -0400 (Wed, 17 Mar 2010)
New Revision: 2079
Modified:
jcr/trunk/exo.jcr.component.core/pom.xml
Log:
EXOJCR-587 testDeleteOrderBefore excluded fixed
Modified: jcr/trunk/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/pom.xml 2010-03-16 15:54:45 UTC (rev 2078)
+++ jcr/trunk/exo.jcr.component.core/pom.xml 2010-03-17 07:57:04 UTC (rev 2079)
@@ -398,7 +398,7 @@
<exclude>org/exoplatform/services/jcr/**/impl/**/TestLinkedWorkspaceStorageCacheMetrics.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/SQLBenchmarkTest.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/TestLockPerstistentDataManager.java</exclude>
- <exclude>org/exoplatform/services/jcr/**/impl/**/TestOrderBefore.java</exclude>
+ <exclude>org/exoplatform/services/jcr/**/api/**/TestOrderBefore.java</exclude>
</excludes>
</configuration>
</plugin>
@@ -668,7 +668,7 @@
<exclude>org/exoplatform/services/jcr/**/impl/**/TestLinkedWorkspaceStorageCacheMetrics.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/SQLBenchmarkTest.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/TestLockPerstistentDataManager.java</exclude>
- <exclude>org/exoplatform/services/jcr/**/impl/**/TestOrderBefore.java</exclude>
+ <exclude>org/exoplatform/services/jcr/**/api/**/TestOrderBefore.java</exclude>
<!-- From TCK -->
<exclude>org/apache/jackrabbit/test/api/TestAll.java</exclude>
<exclude>org/apache/jackrabbit/test/api/**/Abstract*.java</exclude>
16 years, 1 month
exo-jcr SVN: r2078 - in core/trunk: exo.core.component.database/src/main/java/org/exoplatform/services/database/creator and 2 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-03-16 11:54:45 -0400 (Tue, 16 Mar 2010)
New Revision: 2078
Added:
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutor.java
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutorException.java
core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBScriptExecutor.java
Removed:
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreatorException.java
core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java
Modified:
core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml
core/trunk/pom.xml
Log:
EXOJCR-574: rename DBCreator to DBScriptExecutor
Deleted: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java 2010-03-16 15:14:48 UTC (rev 2077)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java 2010-03-16 15:54:45 UTC (rev 2078)
@@ -1,262 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.database.creator;
-
-import org.exoplatform.container.configuration.ConfigurationException;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.container.xml.PropertiesParam;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
-/**
- * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
- * @version $Id: DBCreator.java 111 2010-11-11 11:11:11Z tolusha $
- */
-public class DBCreator
-{
-
- /**
- * Database template.
- */
- public static final String DATABASE_TEMPLATE = "${database}";
-
- /**
- * User name template.
- */
- public static final String USERNAME_TEMPLATE = "${username}";
-
- /**
- * Password template.
- */
- public static final String PASSWORD_TEMPLATE = "${password}";
-
- /**
- * Driver class name.
- */
- protected final String driver;
-
- /**
- * Database url.
- */
- protected final String url;
-
- /**
- * SA user name.
- */
- protected final String userName;
-
- /**
- * SA user's password.
- */
- protected final String password;
-
- /**
- * DB script creation.
- */
- protected final String dbScript;
-
- /**
- * User name for new DB.
- */
- protected final String dbUserName;
-
- /**
- * User's password.
- */
- protected final String dbPassword;
-
- /**
- * DBCreator constructor.
- *
- * @param params
- * Initializations parameters
- */
- public DBCreator(InitParams params) throws ConfigurationException
- {
- if (params == null)
- {
- throw new ConfigurationException("Initializations parameters expected");
- }
-
- PropertiesParam prop = params.getPropertiesParam("db-connection");
-
- if (prop != null)
- {
- this.driver = prop.getProperty("driverClassName");
- this.url = prop.getProperty("url");
- this.userName = prop.getProperty("username");
- this.password = prop.getProperty("password");
- }
- else
- {
- throw new ConfigurationException("db-connection properties expected in initializations parameters");
- }
-
- prop = params.getPropertiesParam("db-creation");
-
- if (prop != null)
- {
- String scriptPath = prop.getProperty("scriptPath");
- if (scriptPath != null)
- {
- try
- {
- dbScript = readScriptResource(scriptPath);
- }
- catch (IOException e)
- {
- throw new ConfigurationException("Can't read script resource " + scriptPath, e);
- }
- }
- else
- {
- throw new ConfigurationException("scriptPath expected in initializations parameters");
- }
-
- this.dbUserName = prop.getProperty("username");
- this.dbPassword = prop.getProperty("password");
- }
- else
- {
- throw new ConfigurationException("db-creation properties expected in initializations parameters");
- }
-
- }
-
- /**
- * Create database using predefined SQL script. Database name passed as parameter,
- * user name and password passed via configuration. In SQL script database name, user name
- * and password defined via templates as ${database}, ${username} and ${password} respectively.
- *
- * @param dbName
- * new database name
- * @throws DBCreatorException
- * if any error occurs
- */
- public void create(String dbName) throws DBCreatorException
- {
- Connection conn = null;
- try
- {
- Class.forName(driver);
- conn = DriverManager.getConnection(url, userName, password);
- }
- catch (SQLException e)
- {
- throw new DBCreatorException("Can't establish the JDBC connection to database " + url, e);
- }
- catch (ClassNotFoundException e)
- {
- throw new DBCreatorException("Can't load the JDBC driver " + driver, e);
- }
-
- try
- {
- conn.setAutoCommit(false);
-
- for (String scr : dbScript.split(";"))
- {
- scr = scr.replace(DATABASE_TEMPLATE, dbName);
- scr = scr.replace(USERNAME_TEMPLATE, dbUserName);
- scr = scr.replace(PASSWORD_TEMPLATE, dbPassword);
-
- String s = cleanWhitespaces(scr.trim());
- if (s.length() > 0)
- {
- conn.createStatement().executeUpdate(s);
- }
- }
- conn.commit();
- }
- catch (SQLException e)
- {
- try
- {
- conn.rollback();
- }
- catch (SQLException e1)
- {
- throw new DBCreatorException("Can't perform rollback", e1);
- }
- throw new DBCreatorException("Can't execute SQL script", e);
- }
- finally
- {
- try
- {
- conn.close();
- }
- catch (SQLException e)
- {
- throw new DBCreatorException("Can't close connection", e);
- }
- }
- }
-
- /**
- * Read SQL script from file resource.
- */
- protected String readScriptResource(String path) throws IOException
- {
- InputStream is = new FileInputStream(path);
- InputStreamReader isr = new InputStreamReader(is);
- try
- {
- StringBuilder sbuff = new StringBuilder();
- char[] buff = new char[is.available()];
- int r = 0;
- while ((r = isr.read(buff)) > 0)
- {
- sbuff.append(buff, 0, r);
- }
-
- return sbuff.toString();
- }
- finally
- {
- is.close();
- }
- }
-
- /**
- * Clean whitespace.
- */
- private String cleanWhitespaces(String string)
- {
- if (string != null)
- {
- char[] cc = string.toCharArray();
- for (int ci = cc.length - 1; ci > 0; ci--)
- {
- if (Character.isWhitespace(cc[ci]))
- {
- cc[ci] = ' ';
- }
- }
- return new String(cc);
- }
- return string;
- }
-}
Deleted: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreatorException.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreatorException.java 2010-03-16 15:14:48 UTC (rev 2077)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreatorException.java 2010-03-16 15:54:45 UTC (rev 2078)
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.database.creator;
-
-/**
- * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
- * @version $Id: DBCreatorException.java 111 2010-11-11 11:11:11Z tolusha $
- */
-public class DBCreatorException extends Exception
-{
-
- /**
- * DBCreationException constructor.
- */
- public DBCreatorException(Throwable e)
- {
- super(e);
- }
-
- /**
- * DBCreationException constructor.
- */
- public DBCreatorException(String message, Throwable e)
- {
- super(message, e);
- }
-}
Added: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutor.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutor.java (rev 0)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutor.java 2010-03-16 15:54:45 UTC (rev 2078)
@@ -0,0 +1,262 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.database.creator;
+
+import org.exoplatform.container.configuration.ConfigurationException;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.PropertiesParam;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+/**
+ * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
+ * @version $Id: DBCreator.java 111 2010-11-11 11:11:11Z tolusha $
+ */
+public class DBScriptExecutor
+{
+
+ /**
+ * Database template.
+ */
+ public static final String DATABASE_TEMPLATE = "${database}";
+
+ /**
+ * User name template.
+ */
+ public static final String USERNAME_TEMPLATE = "${username}";
+
+ /**
+ * Password template.
+ */
+ public static final String PASSWORD_TEMPLATE = "${password}";
+
+ /**
+ * Driver class name.
+ */
+ protected final String driver;
+
+ /**
+ * Database url.
+ */
+ protected final String url;
+
+ /**
+ * SA user name.
+ */
+ protected final String userName;
+
+ /**
+ * SA user's password.
+ */
+ protected final String password;
+
+ /**
+ * DB script creation.
+ */
+ protected final String dbScript;
+
+ /**
+ * User name for new DB.
+ */
+ protected final String dbUserName;
+
+ /**
+ * User's password.
+ */
+ protected final String dbPassword;
+
+ /**
+ * DBScriptExecutor constructor.
+ *
+ * @param params
+ * Initializations parameters
+ */
+ public DBScriptExecutor(InitParams params) throws ConfigurationException
+ {
+ if (params == null)
+ {
+ throw new ConfigurationException("Initializations parameters expected");
+ }
+
+ PropertiesParam prop = params.getPropertiesParam("db-connection");
+
+ if (prop != null)
+ {
+ this.driver = prop.getProperty("driverClassName");
+ this.url = prop.getProperty("url");
+ this.userName = prop.getProperty("username");
+ this.password = prop.getProperty("password");
+ }
+ else
+ {
+ throw new ConfigurationException("db-connection properties expected in initializations parameters");
+ }
+
+ prop = params.getPropertiesParam("db-creation");
+
+ if (prop != null)
+ {
+ String scriptPath = prop.getProperty("scriptPath");
+ if (scriptPath != null)
+ {
+ try
+ {
+ dbScript = readScriptResource(scriptPath);
+ }
+ catch (IOException e)
+ {
+ throw new ConfigurationException("Can't read script resource " + scriptPath, e);
+ }
+ }
+ else
+ {
+ throw new ConfigurationException("scriptPath expected in initializations parameters");
+ }
+
+ this.dbUserName = prop.getProperty("username");
+ this.dbPassword = prop.getProperty("password");
+ }
+ else
+ {
+ throw new ConfigurationException("db-creation properties expected in initializations parameters");
+ }
+
+ }
+
+ /**
+ * Execute DDL script for new database creation. Database name are passed as parameter,
+ * user name and password are passed via configuration. In SQL script database name, user name
+ * and password defined via templates as ${database}, ${username} and ${password} respectively.
+ *
+ * @param dbName
+ * new database name
+ * @throws DBScriptExecutorException
+ * if any error occurs
+ */
+ public void execute(String dbName) throws DBScriptExecutorException
+ {
+ Connection conn = null;
+ try
+ {
+ Class.forName(driver);
+ conn = DriverManager.getConnection(url, userName, password);
+ }
+ catch (SQLException e)
+ {
+ throw new DBScriptExecutorException("Can't establish the JDBC connection to database " + url, e);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new DBScriptExecutorException("Can't load the JDBC driver " + driver, e);
+ }
+
+ try
+ {
+ conn.setAutoCommit(false);
+
+ for (String scr : dbScript.split(";"))
+ {
+ scr = scr.replace(DATABASE_TEMPLATE, dbName);
+ scr = scr.replace(USERNAME_TEMPLATE, dbUserName);
+ scr = scr.replace(PASSWORD_TEMPLATE, dbPassword);
+
+ String s = cleanWhitespaces(scr.trim());
+ if (s.length() > 0)
+ {
+ conn.createStatement().executeUpdate(s);
+ }
+ }
+ conn.commit();
+ }
+ catch (SQLException e)
+ {
+ try
+ {
+ conn.rollback();
+ }
+ catch (SQLException e1)
+ {
+ throw new DBScriptExecutorException("Can't perform rollback", e1);
+ }
+ throw new DBScriptExecutorException("Can't execute SQL script", e);
+ }
+ finally
+ {
+ try
+ {
+ conn.close();
+ }
+ catch (SQLException e)
+ {
+ throw new DBScriptExecutorException("Can't close connection", e);
+ }
+ }
+ }
+
+ /**
+ * Read SQL script from file resource.
+ */
+ protected String readScriptResource(String path) throws IOException
+ {
+ InputStream is = new FileInputStream(path);
+ InputStreamReader isr = new InputStreamReader(is);
+ try
+ {
+ StringBuilder sbuff = new StringBuilder();
+ char[] buff = new char[is.available()];
+ int r = 0;
+ while ((r = isr.read(buff)) > 0)
+ {
+ sbuff.append(buff, 0, r);
+ }
+
+ return sbuff.toString();
+ }
+ finally
+ {
+ is.close();
+ }
+ }
+
+ /**
+ * Clean whitespace.
+ */
+ private String cleanWhitespaces(String string)
+ {
+ if (string != null)
+ {
+ char[] cc = string.toCharArray();
+ for (int ci = cc.length - 1; ci > 0; ci--)
+ {
+ if (Character.isWhitespace(cc[ci]))
+ {
+ cc[ci] = ' ';
+ }
+ }
+ return new String(cc);
+ }
+ return string;
+ }
+}
Added: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutorException.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutorException.java (rev 0)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutorException.java 2010-03-16 15:54:45 UTC (rev 2078)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.database.creator;
+
+/**
+ * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
+ * @version $Id: DBCreatorException.java 111 2010-11-11 11:11:11Z tolusha $
+ */
+public class DBScriptExecutorException extends Exception
+{
+
+ /**
+ * DBCreationException constructor.
+ */
+ public DBScriptExecutorException(Throwable e)
+ {
+ super(e);
+ }
+
+ /**
+ * DBCreationException constructor.
+ */
+ public DBScriptExecutorException(String message, Throwable e)
+ {
+ super(message, e);
+ }
+}
Deleted: core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java
===================================================================
--- core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java 2010-03-16 15:14:48 UTC (rev 2077)
+++ core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java 2010-03-16 15:54:45 UTC (rev 2078)
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.database;
-
-import org.exoplatform.container.PortalContainer;
-import org.exoplatform.services.database.creator.DBCreator;
-import org.exoplatform.services.database.creator.DBCreatorException;
-
-import junit.framework.TestCase;
-
-/**
- * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
- * @version $Id: TestDBCreator.java 111 2010-11-11 11:11:11Z tolusha $
- */
-public class TestDBCreator extends TestCase
-{
-
- protected DBCreator dbCreator;
-
- public void setUp() throws Exception
- {
- PortalContainer container = PortalContainer.getInstance();
- dbCreator = (DBCreator)container.getComponentInstanceOfType(DBCreator.class);
- }
-
- public void testDBCreator() throws Exception
- {
- assertNotNull(dbCreator);
- try
- {
- dbCreator.create("testDB");
- }
- catch (DBCreatorException e)
- {
- fail("Exception should not be thrown.");
- }
- }
-}
Added: core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBScriptExecutor.java
===================================================================
--- core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBScriptExecutor.java (rev 0)
+++ core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBScriptExecutor.java 2010-03-16 15:54:45 UTC (rev 2078)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.database;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.database.creator.DBScriptExecutor;
+import org.exoplatform.services.database.creator.DBScriptExecutorException;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
+ * @version $Id: TestDBCreator.java 111 2010-11-11 11:11:11Z tolusha $
+ */
+public class TestDBScriptExecutor extends TestCase
+{
+
+ protected DBScriptExecutor dbCreator;
+
+ public void setUp() throws Exception
+ {
+ PortalContainer container = PortalContainer.getInstance();
+ dbCreator = (DBScriptExecutor)container.getComponentInstanceOfType(DBScriptExecutor.class);
+ }
+
+ public void testExecute() throws Exception
+ {
+ assertNotNull(dbCreator);
+ try
+ {
+ dbCreator.execute("testDB");
+ }
+ catch (DBScriptExecutorException e)
+ {
+ fail("Exception should not be thrown.");
+ }
+ }
+}
Modified: core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml 2010-03-16 15:14:48 UTC (rev 2077)
+++ core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml 2010-03-16 15:54:45 UTC (rev 2078)
@@ -51,8 +51,8 @@
</component>
<component>
- <key>org.exoplatform.services.database.creator.DBCreator</key>
- <type>org.exoplatform.services.database.creator.DBCreator</type>
+ <key>org.exoplatform.services.database.creator.DBScriptExecutor</key>
+ <type>org.exoplatform.services.database.creator.DBScriptExecutor</type>
<init-params>
<properties-param>
<name>db-connection</name>
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2010-03-16 15:14:48 UTC (rev 2077)
+++ core/trunk/pom.xml 2010-03-16 15:54:45 UTC (rev 2078)
@@ -361,7 +361,7 @@
<excludes>
<exclude>**/*$*</exclude>
<exclude>**/DBCreatorTest.java</exclude>
- <exclude>**/TestDBCreator.java</exclude>
+ <exclude>**/TestDBScriptExecutor.java</exclude>
<exclude>**/TestLDAPService.java</exclude>
<exclude>**/TestNovellLDAPAPI.java</exclude>
<exclude>**/TestStandardLDAPAPI.java</exclude>
16 years, 1 month