Author: nzamosenchuk
Date: 2009-08-27 12:00:24 -0400 (Thu, 27 Aug 2009)
New Revision: 20
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryContainerImpl.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLConnectionFactory.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLMultiDbJDBCConnection.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLSingleDbJDBCConnection.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OracleConnectionFactory.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OraclePoolConnectionFactory.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/WorkspaceStorageConnectionFactory.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceDataContainer.java
Log:
EXOJCR-9: jcr-951, jcr-1119, jcr-1171 fixes are merged to 1.12
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryContainerImpl.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryContainerImpl.java 2009-08-27
14:02:26 UTC (rev 19)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryContainerImpl.java 2009-08-27
16:00:24 UTC (rev 20)
@@ -35,8 +35,7 @@
* @version $Id: InmemoryContainerImpl.java 11907 2008-03-13 15:36:21Z ksm $
*/
-public class InmemoryContainerImpl
- extends WorkspaceDataContainerBase
+public class InmemoryContainerImpl extends WorkspaceDataContainerBase
{
private static Log log = ExoLogger.getLogger("jcr.InmemoryContainerImpl");
@@ -89,6 +88,14 @@
/**
* {@inheritDoc}
*/
+ public WorkspaceStorageConnection openConnection(boolean readOnly) throws
RepositoryException
+ {
+ return new InmemoryStorageConnection(name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public boolean isSame(WorkspaceDataContainer another)
{
return this.equals(another);
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java 2009-08-27
14:02:26 UTC (rev 19)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java 2009-08-27
16:00:24 UTC (rev 20)
@@ -117,6 +117,9 @@
/**
* FIND_VALUE_BY_PROPERTYID_OREDERNUMB.
*/
+ protected String FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID;
+
+ @Deprecated
protected String FIND_VALUE_BY_PROPERTYID_OREDERNUMB;
/**
@@ -311,8 +314,8 @@
* DB_DIALECTS.
*/
public final static String[] DB_DIALECTS =
- {DB_DIALECT_GENERIC, DB_DIALECT_ORACLE, DB_DIALECT_ORACLEOCI,
DB_DIALECT_PGSQL, DB_DIALECT_MYSQL,
- DB_DIALECT_HSQLDB, DB_DIALECT_DB2, DB_DIALECT_DB2V8,
DB_DIALECT_MSSQL, DB_DIALECT_SYBASE,
- DB_DIALECT_DERBY, DB_DIALECT_MYSQL_UTF8, DB_DIALECT_INGRES};
+ {DB_DIALECT_GENERIC, DB_DIALECT_ORACLE, DB_DIALECT_ORACLEOCI, DB_DIALECT_PGSQL,
DB_DIALECT_MYSQL,
+ DB_DIALECT_HSQLDB, DB_DIALECT_DB2, DB_DIALECT_DB2V8, DB_DIALECT_MSSQL,
DB_DIALECT_SYBASE, DB_DIALECT_DERBY,
+ DB_DIALECT_MYSQL_UTF8, DB_DIALECT_INGRES};
}
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2009-08-27
14:02:26 UTC (rev 19)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2009-08-27
16:00:24 UTC (rev 20)
@@ -29,9 +29,7 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import java.util.StringTokenizer;
import javax.jcr.InvalidItemStateException;
@@ -73,9 +71,7 @@
* @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady
Azarenkov</a>
* @version $Id: JDBCStorageConnection.java 34801 2009-07-31 15:44:50Z dkatayev $
*/
-abstract public class JDBCStorageConnection
- extends DBConstants
- implements WorkspaceStorageConnection
+abstract public class JDBCStorageConnection extends DBConstants implements
WorkspaceStorageConnection
{
/**
@@ -110,26 +106,31 @@
protected final List<ValueIOChannel> valueChanges;
/**
- * JDBCStorageConnection constructor.
- *
- * @param dbConnection
- * JDBC connection
- * @param containerName
- * Workspace conatiner name
- * @param valueStorageProvider
- * External Value Storage provider
- * @param maxBufferSize
- * maximum buffer size (config)
- * @param swapDirectory
- * swap directory (config)
- * @param swapCleaner
- * swap cleaner (FileCleaner)
- * @throws SQLException
- * database error
+ * Read-only flag, if true the connection is marked as READ-ONLY.
*/
- protected JDBCStorageConnection(Connection dbConnection, String containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory,
- FileCleaner swapCleaner) throws SQLException
+ protected final boolean readOnly;
+
+ /**
+ * JDBCStorageConnection constructor.
+ *
+ * @param dbConnection
+ * JDBC connection
+ * @param containerName
+ * Workspace conatiner name
+ * @param valueStorageProvider
+ * External Value Storage provider
+ * @param maxBufferSize
+ * maximum buffer size (config)
+ * @param swapDirectory
+ * swap directory (config)
+ * @param swapCleaner
+ * swap cleaner (FileCleaner)
+ * @throws SQLException
+ * database error
+ */
+ protected JDBCStorageConnection(Connection dbConnection, boolean readOnly, String
containerName,
+ ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ throws SQLException
{
this.valueStorageProvider = valueStorageProvider;
@@ -140,6 +141,7 @@
this.containerName = containerName;
this.dbConnection = dbConnection;
+ this.readOnly = readOnly;
// Fix for Sybase jConnect JDBC driver bug.
// Which throws SQLException(JZ016: The AutoCommit option is already set to
@@ -168,7 +170,7 @@
if (obj instanceof JDBCStorageConnection)
{
- JDBCStorageConnection another = (JDBCStorageConnection) obj;
+ JDBCStorageConnection another = (JDBCStorageConnection)obj;
return getJdbcConnection() == another.getJdbcConnection();
}
@@ -274,8 +276,11 @@
checkIfOpened();
try
{
+ // If READ-ONLY status back it to READ-WRITE (we assume it was original state)
+ if (readOnly)
+ dbConnection.setReadOnly(true);
+
dbConnection.close();
-
}
catch (SQLException e)
{
@@ -319,7 +324,7 @@
* {@inheritDoc}
*/
public void add(NodeData data) throws RepositoryException,
UnsupportedOperationException, InvalidItemStateException,
- IllegalStateException
+ IllegalStateException
{
checkIfOpened();
try
@@ -327,7 +332,7 @@
addNodeRecord(data);
if (LOG.isDebugEnabled())
LOG.debug("Node added " + data.getQPath().getAsString() + ",
" + data.getIdentifier() + ", "
- + data.getPrimaryTypeName().getAsString());
+ + data.getPrimaryTypeName().getAsString());
}
catch (SQLException e)
@@ -343,7 +348,7 @@
* {@inheritDoc}
*/
public void add(PropertyData data) throws RepositoryException,
UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
+ InvalidItemStateException, IllegalStateException
{
checkIfOpened();
@@ -360,7 +365,7 @@
catch (IOException e)
{
throw new RepositoryException("Can't read REFERENCE property
(" + data.getQPath() + " "
- + data.getIdentifier() + ") value: " + e.getMessage(),
e);
+ + data.getIdentifier() + ") value: " + e.getMessage(), e);
}
}
@@ -368,7 +373,7 @@
if (LOG.isDebugEnabled())
LOG.debug("Property added " + data.getQPath().getAsString() +
", " + data.getIdentifier()
- + (data.getValues() != null ? ", values count: " +
data.getValues().size() : ", NULL data"));
+ + (data.getValues() != null ? ", values count: " +
data.getValues().size() : ", NULL data"));
}
catch (IOException e)
@@ -389,7 +394,7 @@
* {@inheritDoc}
*/
public void rename(NodeData data) throws RepositoryException,
UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
+ InvalidItemStateException, IllegalStateException
{
checkIfOpened();
@@ -397,8 +402,8 @@
{
if (renameNode(data) <= 0)
throw new JCRInvalidItemStateException("(rename) Node not found " +
data.getQPath().getAsString() + " "
- + data.getIdentifier() + ". Probably was deleted by another
session ", data.getIdentifier(),
- ItemState.RENAMED);
+ + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
+ ItemState.RENAMED);
}
catch (SQLException e)
{
@@ -412,7 +417,7 @@
* {@inheritDoc}
*/
public void delete(NodeData data) throws RepositoryException,
UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
+ InvalidItemStateException, IllegalStateException
{
checkIfOpened();
@@ -423,12 +428,12 @@
int nc = deleteItemByIdentifier(cid);
if (nc <= 0)
throw new JCRInvalidItemStateException("(delete) Node not found " +
data.getQPath().getAsString() + " "
- + data.getIdentifier() + ". Probably was deleted by another
session ", data.getIdentifier(),
- ItemState.DELETED);
+ + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
+ ItemState.DELETED);
if (LOG.isDebugEnabled())
LOG.debug("Node deleted " + data.getQPath().getAsString() + ",
" + data.getIdentifier() + ", "
- + ((NodeData) data).getPrimaryTypeName().getAsString());
+ + ((NodeData)data).getPrimaryTypeName().getAsString());
}
catch (SQLException e)
@@ -443,7 +448,7 @@
* {@inheritDoc}
*/
public void delete(PropertyData data) throws RepositoryException,
UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
+ InvalidItemStateException, IllegalStateException
{
checkIfOpened();
@@ -460,16 +465,16 @@
int nc = deleteItemByIdentifier(cid);
if (nc <= 0)
throw new JCRInvalidItemStateException("(delete) Property not found
" + data.getQPath().getAsString() + " "
- + data.getIdentifier() + ". Probably was deleted by another
session ", data.getIdentifier(),
- ItemState.DELETED);
+ + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
+ ItemState.DELETED);
if (LOG.isDebugEnabled())
LOG.debug("Property deleted "
- + data.getQPath().getAsString()
- + ", "
- + data.getIdentifier()
- + (((PropertyData) data).getValues() != null ? ", values count:
"
- + ((PropertyData) data).getValues().size() : ", NULL
data"));
+ + data.getQPath().getAsString()
+ + ", "
+ + data.getIdentifier()
+ + (((PropertyData)data).getValues() != null ? ", values count:
"
+ + ((PropertyData)data).getValues().size() : ", NULL data"));
}
catch (IOException e)
@@ -490,7 +495,7 @@
* {@inheritDoc}
*/
public void update(NodeData data) throws RepositoryException,
UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
+ InvalidItemStateException, IllegalStateException
{
checkIfOpened();
try
@@ -499,12 +504,12 @@
// order numb update
if (updateNodeByIdentifier(data.getPersistedVersion(),
data.getQPath().getIndex(), data.getOrderNumber(), cid) <= 0)
throw new JCRInvalidItemStateException("(update) Node not found " +
data.getQPath().getAsString() + " "
- + data.getIdentifier() + ". Probably was deleted by another
session ", data.getIdentifier(),
- ItemState.UPDATED);
+ + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
+ ItemState.UPDATED);
if (LOG.isDebugEnabled())
LOG.debug("Node updated " + data.getQPath().getAsString() + ",
" + data.getIdentifier() + ", "
- + data.getPrimaryTypeName().getAsString());
+ + data.getPrimaryTypeName().getAsString());
}
catch (SQLException e)
@@ -519,7 +524,7 @@
* {@inheritDoc}
*/
public void update(PropertyData data) throws RepositoryException,
UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
+ InvalidItemStateException, IllegalStateException
{
checkIfOpened();
@@ -530,8 +535,8 @@
// update type
if (updatePropertyByIdentifier(data.getPersistedVersion(), data.getType(), cid)
<= 0)
throw new JCRInvalidItemStateException("(update) Property not found
" + data.getQPath().getAsString() + " "
- + data.getIdentifier() + ". Probably was deleted by another
session ", data.getIdentifier(),
- ItemState.UPDATED);
+ + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
+ ItemState.UPDATED);
// update reference
try
@@ -546,7 +551,7 @@
catch (IOException e)
{
throw new RepositoryException("Can't update REFERENCE property
(" + data.getQPath() + " "
- + data.getIdentifier() + ") value: " + e.getMessage(),
e);
+ + data.getIdentifier() + ") value: " + e.getMessage(), e);
}
// do Values update: delete all and add all
@@ -555,7 +560,7 @@
if (LOG.isDebugEnabled())
LOG.debug("Property updated " + data.getQPath().getAsString() +
", " + data.getIdentifier()
- + (data.getValues() != null ? ", values count: " +
data.getValues().size() : ", NULL data"));
+ + (data.getValues() != null ? ", values count: " +
data.getValues().size() : ", NULL data"));
}
catch (IOException e)
@@ -583,7 +588,7 @@
ResultSet node =
findChildNodesByParentIdentifier(getInternalId(parent.getIdentifier()));
List<NodeData> childrens = new ArrayList<NodeData>();
while (node.next())
- childrens.add((NodeData) itemData(parent.getQPath(), node, I_CLASS_NODE,
parent.getACL()));
+ childrens.add((NodeData)itemData(parent.getQPath(), node, I_CLASS_NODE,
parent.getACL()));
return childrens;
}
@@ -608,7 +613,7 @@
ResultSet prop =
findChildPropertiesByParentIdentifier(getInternalId(parent.getIdentifier()));
List<PropertyData> children = new ArrayList<PropertyData>();
while (prop.next())
- children.add((PropertyData) itemData(parent.getQPath(), prop,
I_CLASS_PROPERTY, null));
+ children.add((PropertyData)itemData(parent.getQPath(), prop,
I_CLASS_PROPERTY, null));
return children;
}
@@ -679,7 +684,7 @@
List<PropertyData> references = new ArrayList<PropertyData>();
while (refProps.next())
{
- references.add((PropertyData) itemData(null, refProps, I_CLASS_PROPERTY,
null));
+ references.add((PropertyData)itemData(null, refProps, I_CLASS_PROPERTY,
null));
}
return references;
}
@@ -757,7 +762,7 @@
* if connection is closed
*/
protected ItemData getItemByName(NodeData parent, String parentId, QPathEntry name)
throws RepositoryException,
- IllegalStateException
+ IllegalStateException
{
checkIfOpened();
ResultSet item = null;
@@ -818,7 +823,7 @@
throw new InvalidItemStateException("Parent not found, uuid: " +
getIdentifier(caid));
QPathEntry qpe =
- new QPathEntry(InternalQName.parse(parent.getString(COLUMN_NAME)),
parent.getInt(COLUMN_INDEX));
+ new QPathEntry(InternalQName.parse(parent.getString(COLUMN_NAME)),
parent.getInt(COLUMN_INDEX));
qrpath.add(qpe);
caid = parent.getString(COLUMN_PARENTID);
}
@@ -893,7 +898,7 @@
* if Repository error
*/
private List<AccessControlEntry> traverseACLPermissions(String cpid) throws
SQLException, IllegalACLException,
- IllegalNameException, RepositoryException
+ IllegalNameException, RepositoryException
{
String caid = cpid;
while (!caid.equals(Constants.ROOT_PARENT_UUID))
@@ -943,7 +948,7 @@
* if Repository error
*/
private String traverseACLOwner(String cpid) throws SQLException, IllegalACLException,
IllegalNameException,
- RepositoryException
+ RepositoryException
{
String caid = cpid;
@@ -978,7 +983,7 @@
* if Repository error
*/
private AccessControlList traverseACL(String cpid) throws SQLException,
IllegalACLException, IllegalNameException,
- RepositoryException
+ RepositoryException
{
String naOwner = null;
List<AccessControlEntry> naPermissions = null;
@@ -1019,7 +1024,7 @@
}
else
throw new IllegalACLException("ACL is not found for node with id " +
getIdentifier(cpid)
- + " or for its ancestors. But repository is ACL enabled.");
+ + " or for its ancestors. But repository is ACL enabled.");
}
/**
@@ -1040,7 +1045,7 @@
* if invalid QName
*/
private QPath traverseQPath_SP_PGSQL(String cpid) throws SQLException,
InvalidItemStateException,
- IllegalNameException
+ IllegalNameException
{
// get item by Identifier usecase:
// find parent path in db by cpid
@@ -1056,8 +1061,8 @@
try
{
cstmt =
- dbConnection
- .prepareStatement("select * from get_qpath(?) AS (id
varchar, name varchar, parent_id varchar, i_index int)");
+ dbConnection
+ .prepareStatement("select * from get_qpath(?) AS (id varchar, name
varchar, parent_id varchar, i_index int)");
cstmt.setString(1, cpid);
// cstmt.setString(2, caid);
ResultSet parent = cstmt.executeQuery();
@@ -1065,7 +1070,7 @@
while (parent.next())
{
QPathEntry qpe =
- new
QPathEntry(InternalQName.parse(parent.getString(COLUMN_NAME)),
parent.getInt(COLUMN_INDEX));
+ new QPathEntry(InternalQName.parse(parent.getString(COLUMN_NAME)),
parent.getInt(COLUMN_INDEX));
qrpath.add(qpe);
}
@@ -1109,7 +1114,7 @@
* I/O error
*/
private ItemData itemData(QPath parentPath, ResultSet item, int itemClass,
AccessControlList parentACL)
- throws RepositoryException, SQLException, IOException
+ throws RepositoryException, SQLException, IOException
{
String cid = item.getString(COLUMN_ID);
String cname = item.getString(COLUMN_NAME);
@@ -1135,7 +1140,7 @@
catch (InvalidItemStateException e)
{
throw new InvalidItemStateException("FATAL: Can't build item path for
name " + cname + " id: "
- + getIdentifier(cid) + ". " + e);
+ + getIdentifier(cid) + ". " + e);
}
}
@@ -1155,7 +1160,7 @@
* I/O error
*/
private PropertyData propertyData(QPath parentPath, ResultSet item) throws
RepositoryException, SQLException,
- IOException
+ IOException
{
String cid = item.getString(COLUMN_ID);
String cname = item.getString(COLUMN_NAME);
@@ -1171,8 +1176,7 @@
QPath qpath = QPath.makeChildPath(parentPath == null ? traverseQPath(cpid) :
parentPath, qname);
PersistedPropertyData pdata =
- new PersistedPropertyData(getIdentifier(cid), qpath,
getIdentifier(cpid), cversion, cptype,
- cpmultivalued);
+ new PersistedPropertyData(getIdentifier(cid), qpath, getIdentifier(cpid),
cversion, cptype, cpmultivalued);
pdata.setValues(new ArrayList<ValueData>());
return pdata;
@@ -1180,7 +1184,7 @@
catch (InvalidItemStateException e)
{
throw new InvalidItemStateException("FATAL: Can't build property path
for name " + cname + " id: "
- + getIdentifier(cid) + ". " + e);
+ + getIdentifier(cid) + ". " + e);
}
catch (IllegalNameException e)
{
@@ -1355,7 +1359,7 @@
do
{
StringTokenizer parser =
- new StringTokenizer(new String(exoPerm.getBytes(COLUMN_VDATA)),
AccessControlEntry.DELIMITER);
+ new StringTokenizer(new String(exoPerm.getBytes(COLUMN_VDATA)),
AccessControlEntry.DELIMITER);
naPermissions.add(new AccessControlEntry(parser.nextToken(),
parser.nextToken()));
}
while (exoPerm.next());
@@ -1364,7 +1368,7 @@
}
else
throw new IllegalACLException("Property exo:permissions is not found for
node with id: "
- + getIdentifier(cid));
+ + getIdentifier(cid));
}
finally
{
@@ -1425,7 +1429,7 @@
* database error
*/
protected PersistedNodeData loadNodeRecord(QPath parentPath, String cname, String cid,
String cpid, int cindex,
- int cversion, int cnordernumb, AccessControlList parentACL) throws
RepositoryException, SQLException
+ int cversion, int cnordernumb, AccessControlList parentACL) throws
RepositoryException, SQLException
{
try
@@ -1463,11 +1467,10 @@
if (!ptProp.next())
throw new PrimaryTypeNotFoundException("FATAL ERROR primary type
record not found. Node "
- + qpath.getAsString() + ", id " + cid + ",
container " + this.containerName, null);
+ + qpath.getAsString() + ", id " + cid + ", container
" + this.containerName, null);
byte[] data = ptProp.getBytes(COLUMN_VDATA);
- InternalQName ptName = InternalQName.parse(new String((data != null ? data :
new byte[]
- {})));
+ InternalQName ptName = InternalQName.parse(new String((data != null ? data :
new byte[]{})));
// MIXIN
MixinInfo mixins = readMixins(cid);
@@ -1487,8 +1490,8 @@
{
// use permissions from existed parent
acl =
- new AccessControlList(readACLOwner(cid),
parentACL.hasPermissions() ? parentACL
- .getPermissionEntries() : null);
+ new AccessControlList(readACLOwner(cid), parentACL.hasPermissions()
? parentACL
+ .getPermissionEntries() : null);
}
else
{
@@ -1522,8 +1525,8 @@
if (parentACL != null)
// construct ACL from existed parent ACL
acl =
- new AccessControlList(parentACL.getOwner(),
parentACL.hasPermissions() ? parentACL
- .getPermissionEntries() : null);
+ new AccessControlList(parentACL.getOwner(),
parentACL.hasPermissions() ? parentACL
+ .getPermissionEntries() : null);
else
// have to search nearest ancestor owner and permissions in ACL
manager
// acl = traverseACL(cpid);
@@ -1531,12 +1534,12 @@
}
return new PersistedNodeData(getIdentifier(cid), qpath,
getIdentifier(parentCid), cversion, cnordernumb,
- ptName, mixins.mixinNames(), acl);
+ ptName, mixins.mixinNames(), acl);
}
catch (IllegalACLException e)
{
throw new RepositoryException("FATAL ERROR Node " +
getIdentifier(cid) + " " + qpath.getAsString()
- + " has wrong formed ACL. ", e);
+ + " has wrong formed ACL. ", e);
}
}
catch (IllegalNameException e)
@@ -1571,7 +1574,7 @@
* I/O error
*/
protected PersistedPropertyData loadPropertyRecord(QPath parentPath, String cname,
String cid, String cpid,
- int cversion, int cptype, boolean cpmultivalued) throws RepositoryException,
SQLException, IOException
+ int cversion, int cptype, boolean cpmultivalued) throws RepositoryException,
SQLException, IOException
{
// NOTE: cpid never should be null or root parent (' ')
@@ -1579,13 +1582,10 @@
try
{
QPath qpath =
- QPath
- .makeChildPath(parentPath == null ? traverseQPath(cpid) :
parentPath, InternalQName
- .parse(cname));
+ QPath.makeChildPath(parentPath == null ? traverseQPath(cpid) : parentPath,
InternalQName.parse(cname));
PersistedPropertyData pdata =
- new PersistedPropertyData(getIdentifier(cid), qpath,
getIdentifier(cpid), cversion, cptype,
- cpmultivalued);
+ new PersistedPropertyData(getIdentifier(cid), qpath, getIdentifier(cpid),
cversion, cptype, cpmultivalued);
pdata.setValues(readValues(cid, pdata));
return pdata;
@@ -1613,10 +1613,10 @@
* if no such storage found with Value storageId
*/
private void deleteValues(String cid, PropertyData pdata, boolean update) throws
IOException, SQLException,
- ValueStorageNotFoundException
+ ValueStorageNotFoundException
{
- final ResultSet valueRecords = findValuesByPropertyId(cid);
+ final ResultSet valueRecords = findValuesStorageDescriptorsByPropertyId(cid);
try
{
// [PN] 12.07.07 if (... instead while (...
@@ -1627,22 +1627,25 @@
// delete all Values in database
deleteValueData(cid);
- // delete each VS once per Property
- // traverse each ValueData record to be sure all Values Storage data deleted
- Set<String> deletedVS = new HashSet<String>();
- // do { // TODO we need it for multiple VS
- final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC);
- if (!valueRecords.wasNull() && !deletedVS.contains(storageId))
+ do
{
- final ValueIOChannel channel =
valueStorageProvider.getChannel(storageId);
- // delete all Values data in VS
- channel.delete(pdata.getIdentifier());
- deletedVS.add(storageId);
- valueChanges.add(channel);
+ final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC);
+ if (!valueRecords.wasNull())
+ {
+ final ValueIOChannel channel =
valueStorageProvider.getChannel(storageId);
+ try
+ {
+ channel.delete(pdata.getIdentifier());
+ valueChanges.add(channel);
+ }
+ finally
+ {
+ channel.close();
+ }
+ }
}
- // } while (valueRecords.next());
-
- } // else property without Value(s) - it's may means empty Values for
multivalued Property
+ while (valueRecords.next());
+ }
}
finally
{
@@ -1666,7 +1669,7 @@
* if no such storage found with Value storageId
*/
private List<ValueData> readValues(String cid, PropertyData pdata) throws
IOException, SQLException,
- ValueStorageNotFoundException
+ ValueStorageNotFoundException
{
List<ValueData> data = new ArrayList<ValueData>();
@@ -1679,8 +1682,8 @@
final int orderNum = valueRecords.getInt(COLUMN_VORDERNUM);
final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC);
ValueData vdata =
- valueRecords.wasNull() ? readValueData(cid, orderNum,
pdata.getPersistedVersion())
- : readValueData(pdata, orderNum, storageId);
+ valueRecords.wasNull() ? readValueData(cid, orderNum,
pdata.getPersistedVersion(), valueRecords
+ .getBinaryStream(COLUMN_VDATA)) : readValueData(pdata, orderNum,
storageId);
data.add(vdata);
}
}
@@ -1710,7 +1713,7 @@
* if no such storage found with Value storageId
*/
protected ValueData readValueData(PropertyData pdata, int orderNumber, String
storageId) throws SQLException,
- IOException, ValueStorageNotFoundException
+ IOException, ValueStorageNotFoundException
{
ValueIOChannel channel = valueStorageProvider.getChannel(storageId);
try
@@ -1732,13 +1735,15 @@
* Value order number
* @param version
* persistent version (used for BLOB swapping)
+ * @param content
* @return ValueData
* @throws SQLException
* database error
* @throws IOException
* I/O error (swap)
*/
- protected ValueData readValueData(String cid, int orderNumber, int version) throws
SQLException, IOException
+ protected ValueData readValueData(String cid, int orderNumber, int version, final
InputStream content)
+ throws SQLException, IOException
{
ResultSet valueResultSet = null;
@@ -1753,47 +1758,42 @@
try
{
// stream from database
- valueResultSet = findValueByPropertyIdOrderNumber(cid, orderNumber);
- if (valueResultSet.next())
- {
- final InputStream in = valueResultSet.getBinaryStream(COLUMN_VDATA);
- if (in != null)
- while ((read = in.read(spoolBuffer)) >= 0)
+ if (content != null)
+ while ((read = content.read(spoolBuffer)) >= 0)
+ {
+ if (out != null)
{
- if (out != null)
+ // spool to temp file
+ out.write(spoolBuffer, 0, read);
+ len += read;
+ }
+ else if (len + read > maxBufferSize)
+ {
+ // threshold for keeping data in memory exceeded;
+ // create temp file and spool buffer contents
+ swapFile = SwapFile.get(swapDirectory, cid + orderNumber +
"." + version);
+ if (swapFile.isSpooled())
{
- // spool to temp file
- out.write(spoolBuffer, 0, read);
- len += read;
- }
- else if (len + read > maxBufferSize)
- {
- // threshold for keeping data in memory exceeded;
- // create temp file and spool buffer contents
- swapFile = SwapFile.get(swapDirectory, cid + orderNumber +
"." + version);
- if (swapFile.isSpooled())
- {
- // break, value already spooled
- buffer = null;
- break;
- }
- out = new FileOutputStream(swapFile);
- out.write(buffer, 0, len);
- out.write(spoolBuffer, 0, read);
+ // break, value already spooled
buffer = null;
- len += read;
+ break;
}
- else
- {
- // reallocate new buffer and spool old buffer contents
- byte[] newBuffer = new byte[len + read];
- System.arraycopy(buffer, 0, newBuffer, 0, len);
- System.arraycopy(spoolBuffer, 0, newBuffer, len, read);
- buffer = newBuffer;
- len += read;
- }
+ out = new FileOutputStream(swapFile);
+ out.write(buffer, 0, len);
+ out.write(spoolBuffer, 0, read);
+ buffer = null;
+ len += read;
}
- }
+ else
+ {
+ // reallocate new buffer and spool old buffer contents
+ byte[] newBuffer = new byte[len + read];
+ System.arraycopy(buffer, 0, newBuffer, 0, len);
+ System.arraycopy(spoolBuffer, 0, newBuffer, len, read);
+ buffer = newBuffer;
+ len += read;
+ }
+ }
}
finally
{
@@ -1889,17 +1889,20 @@
protected abstract int deleteItemByIdentifier(String identifier) throws SQLException;
protected abstract int updateNodeByIdentifier(int version, int index, int orderNumb,
String identifier)
- throws SQLException;
+ throws SQLException;
protected abstract int updatePropertyByIdentifier(int version, int type, String
identifier) throws SQLException;
// -------- values processing ------------
protected abstract int addValueData(String cid, int orderNumber, InputStream stream,
int streamLength,
- String storageId) throws SQLException;
+ String storageId) throws SQLException;
protected abstract int deleteValueData(String cid) throws SQLException;
protected abstract ResultSet findValuesByPropertyId(String cid) throws SQLException;
+ protected abstract ResultSet findValuesStorageDescriptorsByPropertyId(String cid)
throws SQLException;
+
+ @Deprecated
protected abstract ResultSet findValueByPropertyIdOrderNumber(String cid, int
orderNumb) throws SQLException;
}
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java 2009-08-27
14:02:26 UTC (rev 19)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java 2009-08-27
16:00:24 UTC (rev 20)
@@ -41,8 +41,7 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
* @version $Id: GenericConnectionFactory.java 34801 2009-07-31 15:44:50Z dkatayev $
*/
-public class GenericConnectionFactory
- implements WorkspaceStorageConnectionFactory
+public class GenericConnectionFactory implements WorkspaceStorageConnectionFactory
{
protected final Log log =
ExoLogger.getLogger("jcr.GenericConnectionFactory");
@@ -98,8 +97,8 @@
* - Swap cleaner (internal FileCleaner).
*/
protected GenericConnectionFactory(DataSource dataSource, String dbDriver, String
dbUrl, String dbUserName,
- String dbPassword, String containerName, boolean multiDb,
ValueStoragePluginProvider valueStorageProvider,
- int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
+ String dbPassword, String containerName, boolean multiDb,
ValueStoragePluginProvider valueStorageProvider,
+ int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
{
this.containerName = containerName;
@@ -137,12 +136,11 @@
* - Swap cleaner (internal FileCleaner).
*/
public GenericConnectionFactory(DataSource dataSource, String containerName, boolean
multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory,
- FileCleaner swapCleaner)
+ ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
{
this(dataSource, null, null, null, null, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ swapDirectory, swapCleaner);
}
/**
@@ -170,12 +168,12 @@
* - Swap cleaner (internal FileCleaner).
*/
public GenericConnectionFactory(String dbDriver, String dbUrl, String dbUserName,
String dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
+ File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
{
this(null, dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ swapDirectory, swapCleaner);
try
{
@@ -200,18 +198,25 @@
*/
public WorkspaceStorageConnection openConnection() throws RepositoryException
{
+ return openConnection(false);
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public WorkspaceStorageConnection openConnection(boolean readOnly) throws
RepositoryException
+ {
try
{
if (multiDb)
{
- return new MultiDbJDBCConnection(getJdbcConnection(), containerName,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ return new MultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
}
- return new SingleDbJDBCConnection(getJdbcConnection(), containerName,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ return new SingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName, valueStorageProvider,
+ maxBufferSize, swapDirectory, swapCleaner);
}
catch (SQLException e)
@@ -223,29 +228,40 @@
/**
* {@inheritDoc}
*/
- public Connection getJdbcConnection() throws RepositoryException
+ public Connection getJdbcConnection(boolean readOnly) throws RepositoryException
{
try
{
final Connection conn =
- dbDataSource != null ? dbDataSource.getConnection() : (dbUserName !=
null ? DriverManager
- .getConnection(dbUrl, dbUserName, dbPassword) :
DriverManager.getConnection(dbUrl));
+ dbDataSource != null ? dbDataSource.getConnection() : (dbUserName != null ?
DriverManager.getConnection(
+ dbUrl, dbUserName, dbPassword) : DriverManager.getConnection(dbUrl));
+ if (readOnly) // set this feature only if it asked
+ conn.setReadOnly(readOnly);
+
return monitorInterest == 0 ? conn : new ManagedConnection(conn,
monitorInterest);
}
catch (SQLException e)
{
String err =
- "Error of JDBC connection open. SQLException: " +
e.getMessage() + ", SQLState: " + e.getSQLState()
- + ", VendorError: " + e.getErrorCode();
+ "Error of JDBC connection open. SQLException: " + e.getMessage() +
", SQLState: " + e.getSQLState()
+ + ", VendorError: " + e.getErrorCode();
throw new RepositoryException(err, e);
}
}
/**
- * JDBC monitor init procedure.
- *
+ * {@inheritDoc}
*/
+ public Connection getJdbcConnection() throws RepositoryException
+ {
+ return getJdbcConnection(false);
+ }
+
+ /**
+ * JDBC monitor init procedure.
+ *
+ */
private void initMonitor()
{
String monitor =
System.getProperty(ManagedConnection.JCR_JDBC_CONNECTION_MONITOR);
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLConnectionFactory.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLConnectionFactory.java 2009-08-27
14:02:26 UTC (rev 19)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLConnectionFactory.java 2009-08-27
16:00:24 UTC (rev 20)
@@ -36,8 +36,7 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
* @version $Id: MySQLConnectionFactory.java 34801 2009-07-31 15:44:50Z dkatayev $
*/
-public class MySQLConnectionFactory
- extends GenericConnectionFactory
+public class MySQLConnectionFactory extends GenericConnectionFactory
{
/**
@@ -69,12 +68,12 @@
* if error eccurs
*/
public MySQLConnectionFactory(String dbDriver, String dbUrl, String dbUserName, String
dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ 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);
+ swapDirectory, swapCleaner);
}
/**
@@ -96,8 +95,7 @@
* - Swap cleaner (internal FileCleaner).
*/
public MySQLConnectionFactory(DataSource dbDataSource, String containerName, boolean
multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory,
- FileCleaner swapCleaner)
+ ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
{
super(dbDataSource, containerName, multiDb, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
@@ -107,19 +105,19 @@
* {@inheritDoc}
*/
@Override
- public WorkspaceStorageConnection openConnection() throws RepositoryException
+ public WorkspaceStorageConnection openConnection(boolean readOnly) throws
RepositoryException
{
try
{
if (multiDb)
{
- return new MySQLMultiDbJDBCConnection(getJdbcConnection(), containerName,
valueStorageProvider,
- maxBufferSize, swapDirectory, swapCleaner);
+ return new MySQLMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
}
- return new MySQLSingleDbJDBCConnection(getJdbcConnection(), containerName,
valueStorageProvider,
- maxBufferSize, swapDirectory, swapCleaner);
+ return new MySQLSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
}
catch (SQLException e)
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLMultiDbJDBCConnection.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLMultiDbJDBCConnection.java 2009-08-27
14:02:26 UTC (rev 19)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLMultiDbJDBCConnection.java 2009-08-27
16:00:24 UTC (rev 20)
@@ -36,8 +36,7 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
* @version $Id: MySQLMultiDbJDBCConnection.java 34801 2009-07-31 15:44:50Z dkatayev $
*/
-public class MySQLMultiDbJDBCConnection
- extends MultiDbJDBCConnection
+public class MySQLMultiDbJDBCConnection extends MultiDbJDBCConnection
{
/**
@@ -45,6 +44,8 @@
*
* @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
@@ -59,12 +60,12 @@
*
* @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
*/
- public MySQLMultiDbJDBCConnection(Connection dbConnection, String containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory,
- FileCleaner swapCleaner) throws SQLException
+ public MySQLMultiDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
+ ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ throws SQLException
{
- super(dbConnection, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
}
/**
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLSingleDbJDBCConnection.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLSingleDbJDBCConnection.java 2009-08-27
14:02:26 UTC (rev 19)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLSingleDbJDBCConnection.java 2009-08-27
16:00:24 UTC (rev 20)
@@ -36,8 +36,7 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
* @version $Id: MySQLSingleDbJDBCConnection.java 34801 2009-07-31 15:44:50Z dkatayev $
*/
-public class MySQLSingleDbJDBCConnection
- extends SingleDbJDBCConnection
+public class MySQLSingleDbJDBCConnection extends SingleDbJDBCConnection
{
/**
@@ -45,6 +44,8 @@
*
* @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
@@ -59,12 +60,12 @@
*
* @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
*/
- public MySQLSingleDbJDBCConnection(Connection dbConnection, String containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory,
- FileCleaner swapCleaner) throws SQLException
+ public MySQLSingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String
containerName,
+ ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ throws SQLException
{
- super(dbConnection, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
}
/**
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OracleConnectionFactory.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OracleConnectionFactory.java 2009-08-27
14:02:26 UTC (rev 19)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OracleConnectionFactory.java 2009-08-27
16:00:24 UTC (rev 20)
@@ -41,8 +41,7 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
* @version $Id: OracleConnectionFactory.java 34801 2009-07-31 15:44:50Z dkatayev $
*/
-public class OracleConnectionFactory
- extends GenericConnectionFactory
+public class OracleConnectionFactory extends GenericConnectionFactory
{
public static int CONNCACHE_MAX_LIMIT = 25;
@@ -82,8 +81,8 @@
* if error occurs
*/
public OracleConnectionFactory(String dbDriver, String dbUrl, String dbUserName,
String dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
+ File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
{
// ;D:\Devel\oracle_instantclient_10_2\;C:\oracle\ora92\bin;
@@ -112,16 +111,14 @@
*/
super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ swapDirectory, swapCleaner);
Object cds = null;
try
{
Class cdsClass =
OracleConnectionFactory.class.getClassLoader().loadClass("oracle.jdbc.pool.OracleDataSource");
- Constructor cdsConstructor = cdsClass.getConstructor(new Class[]
- {});
- cds = cdsConstructor.newInstance(new Object[]
- {});
+ Constructor cdsConstructor = cdsClass.getConstructor(new Class[]{});
+ cds = cdsConstructor.newInstance(new Object[]{});
// set cache properties
Properties prop = new java.util.Properties();
@@ -131,35 +128,25 @@
prop.setProperty("InactivityTimeout",
String.valueOf(CONNCACHE_INACTIVITY_TIMEOUT));
prop.setProperty("AbandonedConnectionTimeout",
String.valueOf(CONNCACHE_ABADONDED_TIMEOUT));
- Method setURL = cds.getClass().getMethod("setURL", new Class[]
- {String.class});
- setURL.invoke(cds, new Object[]
- {this.dbUrl});
+ Method setURL = cds.getClass().getMethod("setURL", new
Class[]{String.class});
+ setURL.invoke(cds, new Object[]{this.dbUrl});
- Method setUser = cds.getClass().getMethod("setUser", new Class[]
- {String.class});
- setUser.invoke(cds, new Object[]
- {this.dbUserName});
+ Method setUser = cds.getClass().getMethod("setUser", new
Class[]{String.class});
+ setUser.invoke(cds, new Object[]{this.dbUserName});
- Method setPassword = cds.getClass().getMethod("setPassword", new
Class[]
- {String.class});
- setPassword.invoke(cds, new Object[]
- {this.dbPassword});
+ Method setPassword = cds.getClass().getMethod("setPassword", new
Class[]{String.class});
+ setPassword.invoke(cds, new Object[]{this.dbPassword});
- Method setConnectionCachingEnabled =
cds.getClass().getMethod("setConnectionCachingEnabled", new Class[]
- {boolean.class});
- setConnectionCachingEnabled.invoke(cds, new Object[]
- {true});
+ Method setConnectionCachingEnabled =
+ cds.getClass().getMethod("setConnectionCachingEnabled", new
Class[]{boolean.class});
+ setConnectionCachingEnabled.invoke(cds, new Object[]{true});
- Method setConnectionCacheProperties =
cds.getClass().getMethod("setConnectionCacheProperties", new Class[]
- {Properties.class});
- setConnectionCacheProperties.invoke(cds, new Object[]
- {prop});
+ Method setConnectionCacheProperties =
+ cds.getClass().getMethod("setConnectionCacheProperties", new
Class[]{Properties.class});
+ setConnectionCacheProperties.invoke(cds, new Object[]{prop});
- Method setConnectionCacheName =
cds.getClass().getMethod("setConnectionCacheName", new Class[]
- {String.class});
- setConnectionCacheName.invoke(cds, new Object[]
- {"EXOJCR_OCI__" + containerName});
+ Method setConnectionCacheName =
cds.getClass().getMethod("setConnectionCacheName", new Class[]{String.class});
+ setConnectionCacheName.invoke(cds, new Object[]{"EXOJCR_OCI__" +
containerName});
}
catch (Throwable e)
@@ -183,23 +170,28 @@
* {@inheritDoc}
*/
@Override
- public Connection getJdbcConnection() throws RepositoryException
+ public Connection getJdbcConnection(boolean readOnly) throws RepositoryException
{
if (ociDataSource != null)
try
{
- return getCachedConnection();
+ Connection conn = getCachedConnection();
+
+ if (readOnly) // set this feature only if it asked
+ conn.setReadOnly(true);
+
+ return conn;
}
catch (Throwable e)
{
throw new RepositoryException("Oracle OCI cached connection open error
" + e, e);
}
- return super.getJdbcConnection();
+ return super.getJdbcConnection(readOnly);
}
/**
- * getCachedConnection.
+ * Get CachedConnection.
*
* @return
* @throws NoSuchMethodException
@@ -208,14 +200,12 @@
* @throws InvocationTargetException
*/
protected Connection getCachedConnection() throws NoSuchMethodException,
IllegalArgumentException,
- IllegalAccessException, InvocationTargetException
+ IllegalAccessException, InvocationTargetException
{
// NOTE: ociDataSource - actually instance of javax.sql.DataSource
- Method getConnection =
ociDataSource.getClass().getMethod("getConnection", new Class[]
- {});
- Connection conn = (Connection) getConnection.invoke(ociDataSource, new Object[]
- {});
+ Method getConnection =
ociDataSource.getClass().getMethod("getConnection", new Class[]{});
+ Connection conn = (Connection)getConnection.invoke(ociDataSource, new Object[]{});
return conn;
}
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OraclePoolConnectionFactory.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OraclePoolConnectionFactory.java 2009-08-27
14:02:26 UTC (rev 19)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OraclePoolConnectionFactory.java 2009-08-27
16:00:24 UTC (rev 20)
@@ -38,8 +38,7 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
* @version $Id: OraclePoolConnectionFactory.java 34801 2009-07-31 15:44:50Z dkatayev $
*/
-public class OraclePoolConnectionFactory
- extends GenericConnectionFactory
+public class OraclePoolConnectionFactory extends GenericConnectionFactory
{
public static int CONNPOOL_MAX_LIMIT = 20;
@@ -77,8 +76,8 @@
* if error occurs
*/
public OraclePoolConnectionFactory(String dbDriver, String dbUrl, String dbUserName,
String dbPassword,
- String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
+ File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
{
// ;D:\Devel\oracle_instantclient_10_2\;C:\oracle\ora92\bin;
@@ -107,23 +106,20 @@
*/
super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ swapDirectory, swapCleaner);
Object cpool = null;
try
{
Class cpoolClass =
- OraclePoolConnectionFactory.class.getClassLoader().loadClass(
- "oracle.jdbc.pool.OracleOCIConnectionPool");
- Constructor cpoolConstructor = cpoolClass.getConstructor(new Class[]
- {String.class, String.class, String.class, Properties.class});
+
OraclePoolConnectionFactory.class.getClassLoader().loadClass("oracle.jdbc.pool.OracleOCIConnectionPool");
+ Constructor cpoolConstructor =
+ cpoolClass.getConstructor(new Class[]{String.class, String.class,
String.class, Properties.class});
- cpool = cpoolConstructor.newInstance(new Object[]
- {this.dbUserName, this.dbPassword, this.dbUrl, null});
- Method setConnectionCachingEnabled =
cpool.getClass().getMethod("setConnectionCachingEnabled", new Class[]
- {boolean.class});
- setConnectionCachingEnabled.invoke(cpool, new Object[]
- {true});
+ cpool = cpoolConstructor.newInstance(new Object[]{this.dbUserName,
this.dbPassword, this.dbUrl, null});
+ Method setConnectionCachingEnabled =
+ cpool.getClass().getMethod("setConnectionCachingEnabled", new
Class[]{boolean.class});
+ setConnectionCachingEnabled.invoke(cpool, new Object[]{true});
}
catch (Throwable e)
{
@@ -160,19 +156,24 @@
* {@inheritDoc}
*/
@Override
- public Connection getJdbcConnection() throws RepositoryException
+ public Connection getJdbcConnection(boolean readOnly) throws RepositoryException
{
if (ociPool != null)
try
{
- return getPoolConnection();
+ Connection conn = getPoolConnection();
+
+ if (readOnly) // set this feature only if it asked
+ conn.setReadOnly(true);
+
+ return conn;
}
catch (Throwable e)
{
throw new RepositoryException("Oracle OCI pool connection open error
" + e, e);
}
- return super.getJdbcConnection();
+ return super.getJdbcConnection(readOnly);
}
/**
@@ -185,33 +186,29 @@
* @throws InvocationTargetException
*/
protected Connection getPoolConnection() throws NoSuchMethodException,
IllegalArgumentException,
- IllegalAccessException, InvocationTargetException
+ IllegalAccessException, InvocationTargetException
{
- Method getConnection = ociPool.getClass().getMethod("getConnection", new
Class[]
- {});
- return (Connection) getConnection.invoke(ociPool, new Object[]
- {});
+ Method getConnection = ociPool.getClass().getMethod("getConnection", new
Class[]{});
+ return (Connection)getConnection.invoke(ociPool, new Object[]{});
}
protected void reconfigure() throws NoSuchMethodException, IllegalArgumentException,
IllegalAccessException,
- InvocationTargetException, NoSuchFieldException
+ InvocationTargetException, NoSuchFieldException
{
if (ociPool != null)
{
// Set up the initial pool configuration
Properties p1 = new Properties();
- String minLimitName = (String)
ociPool.getClass().getField("CONNPOOL_MIN_LIMIT").get(null);
- String maxLimitName = (String)
ociPool.getClass().getField("CONNPOOL_MAX_LIMIT").get(null);
- String incrName = (String)
ociPool.getClass().getField("CONNPOOL_INCREMENT").get(null);
+ String minLimitName =
(String)ociPool.getClass().getField("CONNPOOL_MIN_LIMIT").get(null);
+ String maxLimitName =
(String)ociPool.getClass().getField("CONNPOOL_MAX_LIMIT").get(null);
+ String incrName =
(String)ociPool.getClass().getField("CONNPOOL_INCREMENT").get(null);
p1.put(minLimitName, Integer.toString(CONNPOOL_MIN_LIMIT));
p1.put(maxLimitName, Integer.toString(CONNPOOL_MAX_LIMIT));
p1.put(incrName, Integer.toString(CONNPOOL_INCREMENT));
// Enable the initial configuration
- ociPool.getClass().getMethod("setPoolConfig", new Class[]
- {Properties.class}).invoke(ociPool, new Object[]
- {p1});
+ ociPool.getClass().getMethod("setPoolConfig", new
Class[]{Properties.class}).invoke(ociPool, new Object[]{p1});
}
}
@@ -219,28 +216,24 @@
* Display the current status of the OracleOCIConnectionPool.
*/
protected void displayPoolConfig() throws NoSuchMethodException,
IllegalArgumentException, IllegalAccessException,
- InvocationTargetException
+ InvocationTargetException
{
if (ociPool != null)
{
log.info(" =========== Oracle OCI connection pool config ===========
");
- log.info(" Min poolsize Limit:\t" +
ociPool.getClass().getMethod("getMinLimit", new Class[]
- {}).invoke(ociPool, new Object[]
- {}));
+ log.info(" Min poolsize Limit:\t"
+ + ociPool.getClass().getMethod("getMinLimit", new
Class[]{}).invoke(ociPool, new Object[]{}));
- log.info(" Max poolsize Limit:\t" +
ociPool.getClass().getMethod("getMaxLimit", new Class[]
- {}).invoke(ociPool, new Object[]
- {}));
+ log.info(" Max poolsize Limit:\t"
+ + ociPool.getClass().getMethod("getMaxLimit", new
Class[]{}).invoke(ociPool, new Object[]{}));
- log.info(" PoolSize:\t\t\t" +
ociPool.getClass().getMethod("getPoolSize", new Class[]
- {}).invoke(ociPool, new Object[]
- {}));
+ log.info(" PoolSize:\t\t\t"
+ + ociPool.getClass().getMethod("getPoolSize", new
Class[]{}).invoke(ociPool, new Object[]{}));
- log.info(" ActiveSize:\t\t" +
ociPool.getClass().getMethod("getActiveSize", new Class[]
- {}).invoke(ociPool, new Object[]
- {}));
+ log.info(" ActiveSize:\t\t"
+ + ociPool.getClass().getMethod("getActiveSize", new
Class[]{}).invoke(ociPool, new Object[]{}));
}
}
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/WorkspaceStorageConnectionFactory.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/WorkspaceStorageConnectionFactory.java 2009-08-27
14:02:26 UTC (rev 19)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/WorkspaceStorageConnectionFactory.java 2009-08-27
16:00:24 UTC (rev 20)
@@ -43,11 +43,36 @@
WorkspaceStorageConnection openConnection() throws RepositoryException;
/**
+ * Open connection to Workspace storage.
+ *
+ * @param readOnly
+ * boolean, if true the Connection will be marked as read-only
+ *
+ * @return WorkspaceStorageConnection connection
+ * @throws RepositoryException
+ * if error occurs
+ */
+ WorkspaceStorageConnection openConnection(boolean readOnly) throws
RepositoryException;
+
+ /**
+ * Return native JDBC Connection to workspace storage (JDBC specific).
+ *
+ * @return java.sql.Connection connection
+ * @throws RepositoryException
+ * if error occurs
+ */
+ Connection getJdbcConnection() throws RepositoryException;
+
+ /**
* Return native JDBC Connection to workspace storage (JDBC specific).
*
+ * @param readOnly
+ * boolean, if true the JDBC Connection will be marked as read-only, see
+ * {@link java.sql.Connection#setReadOnly(boolean)}
+ *
* @return java.sql.Connection connection
* @throws RepositoryException
* if error occurs
*/
- Connection getJdbcConnection() throws RepositoryException;
+ Connection getJdbcConnection(boolean readOnly) throws RepositoryException;
}
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceDataContainer.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceDataContainer.java 2009-08-27
14:02:26 UTC (rev 19)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceDataContainer.java 2009-08-27
16:00:24 UTC (rev 20)
@@ -32,8 +32,7 @@
* @version $Id: WorkspaceDataContainer.java 11907 2008-03-13 15:36:21Z ksm $
*/
-public interface WorkspaceDataContainer
- extends DataContainer
+public interface WorkspaceDataContainer extends DataContainer
{
// configuration params
@@ -70,12 +69,24 @@
WorkspaceStorageConnection openConnection() throws RepositoryException;
/**
- * @return the connection to workspace storage, if it possible the connection will use
same
- * physical resource (already obtained) as original connection, otherwise same
behaviour
- * will be used as for openConnection().
+ * Open connection and marked it as READ-ONLY if <code>readOnly</code> is
true. <br/>
+ * EXPERIMENTAL! Use it with care.
*
- * normally implementation of this method should be synchronized
+ * @param readOnly
+ * boolean, if true the Connection will be marked as READ-ONLY
+ *
+ * @return the new connection to workspace storage normally implementation of this
method should
+ * be synchronized
*/
+ WorkspaceStorageConnection openConnection(boolean readOnly) throws
RepositoryException;
+
+ /**
+ * @return the connection to workspace storage, if it possible the connection will
use same
+ * physical resource (already obtained) as original connection, otherwise
same behaviour
+ * will be used as for openConnection().
+ *
+ * normally implementation of this method should be synchronized
+ */
WorkspaceStorageConnection reuseConnection(WorkspaceStorageConnection original) throws
RepositoryException;
}