Author: sergiykarpenko
Date: 2010-02-04 05:42:45 -0500 (Thu, 04 Feb 2010)
New Revision: 1675
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/LockJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/LockPersistentDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/lock-jdbc.default.sql
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/lock-jdbc.ora.sql
Log:
EXOJCR-472: LockPersisterDataManager updated
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/LockJDBCConnection.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/LockJDBCConnection.java 2010-02-04
09:59:43 UTC (rev 1674)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/LockJDBCConnection.java 2010-02-04
10:42:45 UTC (rev 1675)
@@ -44,10 +44,18 @@
protected String REMOVE_LOCK_DATA;
+ protected String REFRESH_LOCK_DATA;
+
+ protected String GET_LOCKED_NODES;
+
private PreparedStatement insertLockData;
private PreparedStatement removeLockData;
+ private PreparedStatement refreshLockData;
+
+ private PreparedStatement getLockedNodes;
+
private Connection dbConnection;
public LockJDBCConnection(Connection dbConnection, String wsName) throws SQLException
@@ -84,6 +92,12 @@
REMOVE_LOCK_DATA = "delete from JCR_LOCKS where WS_NAME=" + wsName +
" and NODE_ID=?";
+ REFRESH_LOCK_DATA =
+ // TODO check list of updated columns
+ "update JCR_LOCKS set OWNER=?, IS_SESSIONSCOPED=?, IS_DEEP=?, BIRTHDAY=?,
TIMEOUT=? where NODE_ID=?";
+
+ GET_LOCKED_NODES = "select NODE_ID from JCR_LOCKS where WS_NAME=" +
wsName;
+
}
public int addLockData(LockData data) throws LockException
@@ -144,7 +158,32 @@
*/
public int refreshLockData(LockData data) throws LockException
{
- return 0;
+ if (!isOpened())
+ {
+ throw new IllegalStateException("Connection is closed");
+ }
+ try
+ {
+ if (refreshLockData == null)
+ refreshLockData = dbConnection.prepareStatement(REFRESH_LOCK_DATA);
+ else
+ refreshLockData.clearParameters();
+
+ //update JCR_LOCKS set OWNER=?, IS_SESSIONSCOPED=?, IS_DEEP=?, BIRTHDAY=?,
TIMEOUT=? where NODE_ID=?;
+
+ refreshLockData.setString(1, data.getOwner());
+ refreshLockData.setBoolean(2, data.isSessionScoped());
+ refreshLockData.setBoolean(3, data.isDeep());
+ refreshLockData.setLong(4, data.getBirthDay());
+ refreshLockData.setLong(5, data.getTimeOut());
+ refreshLockData.setString(6, data.getNodeIdentifier());
+
+ return removeLockData.executeUpdate();
+ }
+ catch (SQLException e)
+ {
+ throw new LockException(e);
+ }
}
/**
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/LockPersistentDataManager.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/LockPersistentDataManager.java 2010-02-04
09:59:43 UTC (rev 1674)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/LockPersistentDataManager.java 2010-02-04
10:42:45 UTC (rev 1675)
@@ -29,6 +29,7 @@
import java.sql.SQLException;
import javax.jcr.RepositoryException;
+import javax.jcr.lock.LockException;
import javax.naming.InitialContext;
import javax.sql.DataSource;
@@ -75,7 +76,8 @@
{
throw new RepositoryException(e);
}
- catch (IOException e) {
+ catch (IOException e)
+ {
throw new RepositoryException(e);
}
finally
@@ -106,7 +108,7 @@
}
- public LockJDBCConnection openConnection(boolean readOnly) throws RepositoryException
+ public LockJDBCConnection openConnection(boolean readOnly) throws LockException
{
try
{
@@ -114,7 +116,7 @@
}
catch (SQLException e)
{
- throw new RepositoryException(e);
+ throw new LockException(e);
}
}
@@ -126,20 +128,20 @@
* @throws RepositoryException
* @throws RepositoryException
*/
- private Connection getJDBCConnection() throws RepositoryException
+ private Connection getJDBCConnection() throws LockException
{
try
{
//TODO make connection as in GenericConnectionFactory
- final Connection conn = dataSource.getConnection();
- return conn;
+ return dataSource.getConnection();
+
}
catch (SQLException e)
{
String err =
"Error of JDBC connection open. SQLException: " + e.getMessage() +
", SQLState: " + e.getSQLState()
+ ", VendorError: " + e.getErrorCode();
- throw new RepositoryException(err, e);
+ throw new LockException(err, e);
}
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/lock-jdbc.default.sql
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/lock-jdbc.default.sql 2010-02-04
09:59:43 UTC (rev 1674)
+++
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/lock-jdbc.default.sql 2010-02-04
10:42:45 UTC (rev 1675)
@@ -7,4 +7,6 @@
IS_DEEP CHAR NOT NULL,
BIRTHDAY BIGINT NOT NULL,
TIMEOUT BIGINT NOT NULL
-);
\ No newline at end of file
+);
+CREATE INDEX JCR_ALL_WS_LOCKS ON JCR_LOCKS(WS_NAME, NODE_ID);
+CREATE UNIQUE INDEX JCR_LOCKS_BY_ID ON JCR_LOCKS(NODE_ID);
Modified:
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/lock-jdbc.ora.sql
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/lock-jdbc.ora.sql 2010-02-04
09:59:43 UTC (rev 1674)
+++
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/lock-jdbc.ora.sql 2010-02-04
10:42:45 UTC (rev 1675)
@@ -9,4 +9,8 @@
BIRTHDAY LONG NOT NULL,
TIMEOUT LONG NOT NULL
)
+/
+CREATE INDEX JCR_ALL_WS_LOCKS ON JCR_LOCKS(WS_NAME, NODE_ID)
+/
+CREATE UNIQUE INDEX JCR_LOCKS_BY_ID ON JCR_LOCKS(NODE_ID)
/
\ No newline at end of file