[exo-jcr-commits] exo-jcr SVN: r1504 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: storage/jdbc and 2 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Jan 20 07:46:45 EST 2010
Author: pnedonosko
Date: 2010-01-20 07:46:45 -0500 (Wed, 20 Jan 2010)
New Revision: 1504
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBConnectionFactory.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
Log:
EXOJCR-404 impl of Value will null file load (swap file actually)
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-01-20 12:41:55 UTC (rev 1503)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-01-20 12:46:45 UTC (rev 1504)
@@ -24,8 +24,10 @@
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache;
import org.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
import org.exoplatform.services.transaction.TransactionService;
@@ -433,12 +435,37 @@
{
data = getPersistedItemData(parentData, name);
}
- // else if (!data.isNode() && ((PropertyData)data).getValues() == null)
- // {
- // // refill the property data if values invalid (null)
- // data = fillPropertyValue((PropertyData)data);
- // }
+ else if (!data.isNode())
+ {
+ PropertyData prop = (PropertyData)data;
+ List<ValueData> vals = prop.getValues();
+ for (int i = 0; i < vals.size(); i++)
+ {
+ ValueData vd = vals.get(i);
+ if (!vd.isByteArray())
+ {
+ // check if file is correct
+ FilePersistedValueData fpvd = (FilePersistedValueData)vd;
+ if (fpvd.getFile() == null)
+ {
+ // need read from storage
+ ValueData svd =
+ getPropertyValue(prop.getIdentifier(), vd.getOrderNumber(), prop.getPersistedVersion());
+ if (svd == null)
+ {
+ // error, value not found
+ throw new RepositoryException("Value cannot be found in storage for cached Property "
+ + prop.getQPath().getAsString() + ", orderNumb:" + vd.getOrderNumber() + ", pversion:"
+ + prop.getPersistedVersion());
+ }
+
+ vals.set(i, vd);
+ }
+ }
+ }
+ }
+
return data;
}
@@ -739,27 +766,26 @@
return transactionManager != null;
}
- // /**
- // * Fill Property Value from persistent storage.
- // *
- // * @param prop PropertyData, original Property data
- // * @return PropertyData
- // * @throws IllegalStateException
- // * @throws RepositoryException
- // */
- // protected PropertyData fillPropertyValue(PropertyData prop) throws IllegalStateException, RepositoryException
- // {
- // // TODO use interface not JDBC
- // JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();
- // try
- // {
- // return new PersistedPropertyData(prop.getIdentifier(), prop.getQPath(), prop.getParentIdentifier(), prop
- // .getPersistedVersion(), prop.getType(), prop.isMultiValued(), conn.getPropertyValues(prop.getIdentifier(),
- // prop.getPersistedVersion()));
- // }
- // finally
- // {
- // conn.close();
- // }
- // }
+ /**
+ * Fill Property Value from persistent storage.
+ *
+ * @param prop PropertyData, original Property data
+ * @return PropertyData
+ * @throws IllegalStateException
+ * @throws RepositoryException
+ */
+ protected ValueData getPropertyValue(String propertyId, int orderNumb, int persistedVersion)
+ throws IllegalStateException, RepositoryException
+ {
+ // TODO use interface not JDBC
+ JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();
+ try
+ {
+ return conn.getValue(propertyId, orderNumb, persistedVersion);
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
}
\ No newline at end of file
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java 2010-01-20 12:41:55 UTC (rev 1503)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java 2010-01-20 12:46:45 UTC (rev 1504)
@@ -21,6 +21,7 @@
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.dataflow.AbstractPersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
+import org.exoplatform.services.jcr.impl.util.io.SwapFile;
import java.io.Externalizable;
import java.io.File;
@@ -76,7 +77,7 @@
this.file = file;
}
- public File getFile() throws IOException
+ public File getFile()
{
return file;
}
@@ -165,23 +166,15 @@
if (!isByteArray() && !another.isByteArray())
{
// compare files
- try
+ if (another instanceof TransientValueData)
{
- if (another instanceof TransientValueData)
- {
- // if another transient
- return file.equals(((TransientValueData)another).getSpoolFile());
- }
- else if (another instanceof FilePersistedValueData)
- {
- // both from peristent layer
- return file.equals(((FilePersistedValueData)another).getFile());
- }
+ // if another transient
+ return file.equals(((TransientValueData)another).getSpoolFile());
}
- catch (IOException e)
+ else if (another instanceof FilePersistedValueData)
{
- LOG.error("Read error", e);
- return false;
+ // both from peristent layer
+ return file.equals(((FilePersistedValueData)another).getFile());
}
}
return false;
@@ -244,11 +237,21 @@
byte[] buf = new byte[size];
in.readFully(buf);
- file = new File(new String(buf, "UTF-8"));
+ File f = new File(new String(buf, "UTF-8"));
+ // validate if exists
+ if (f.exists())
+ {
+ file = f;
+ }
+ else
+ {
+ file = null;
+ }
}
else
{
- throw new IOException("Persisted ValueData with null file found");
+ // should not occurs
+ throw new IOException("readExternal: Persisted ValueData with null file found");
}
}
@@ -268,7 +271,7 @@
}
else
{
- throw new IOException("Persisted ValueData with null file found");
+ throw new IOException("writeExternal: Persisted ValueData with null file found");
}
}
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java 2010-01-20 12:41:55 UTC (rev 1503)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java 2010-01-20 12:46:45 UTC (rev 1504)
@@ -119,7 +119,9 @@
*/
protected String FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID;
- @Deprecated
+ /**
+ * FIND_VALUE_BY_PROPERTYID_OREDERNUMB.
+ */
protected String FIND_VALUE_BY_PROPERTYID_OREDERNUMB;
/**
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2010-01-20 12:41:55 UTC (rev 1503)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2010-01-20 12:46:45 UTC (rev 1504)
@@ -71,7 +71,7 @@
* @author <a href="mailto:gennady.azarenkov at 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
+public abstract class JDBCStorageConnection extends DBConstants implements WorkspaceStorageConnection
{
/**
@@ -783,6 +783,47 @@
}
}
+ /**
+ * Reads Property Value from persistent storage.
+ *
+ * @param propertyId String, Property id
+ * @param orderNumb int, Value order number (in list of values)
+ * @param persistedVersion int
+ * @return ValueData
+ * @throws RepositoryException if read error occurs
+ */
+ public ValueData getValue(String propertyId, int orderNumb, int persistedVersion) throws RepositoryException
+ {
+ try
+ {
+ final String cid = getInternalId(propertyId);
+ final ResultSet valueRecord = findValueByPropertyIdOrderNumber(cid, orderNumb);
+ try
+ {
+ if (valueRecord.next())
+ {
+ final String storageId = valueRecord.getString(COLUMN_VSTORAGE_DESC);
+ return valueRecord.wasNull() ? readValueData(cid, orderNumb, persistedVersion, valueRecord
+ .getBinaryStream(COLUMN_VDATA)) : readValueData(propertyId, orderNumb, storageId);
+ }
+ }
+ finally
+ {
+ valueRecord.close();
+ }
+
+ return null;
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
// ------------------ Private methods ---------------
/**
@@ -2016,6 +2057,5 @@
protected abstract ResultSet findValuesStorageDescriptorsByPropertyId(String cid) throws SQLException;
- @Deprecated
protected abstract ResultSet findValueByPropertyIdOrderNumber(String cid, int orderNumb) throws SQLException;
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java 2010-01-20 12:41:55 UTC (rev 1503)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java 2010-01-20 12:46:45 UTC (rev 1504)
@@ -73,7 +73,6 @@
protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
- @Deprecated
protected PreparedStatement findValueByPropertyIdOrderNumber;
protected PreparedStatement findNodesByParentId;
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java 2010-01-20 12:41:55 UTC (rev 1503)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java 2010-01-20 12:46:45 UTC (rev 1504)
@@ -551,13 +551,16 @@
/**
* {@inheritDoc}
*/
- @Deprecated
protected ResultSet findValueByPropertyIdOrderNumber(String cid, int orderNumb) throws SQLException
{
if (findValueByPropertyIdOrderNumber == null)
+ {
findValueByPropertyIdOrderNumber = dbConnection.prepareStatement(FIND_VALUE_BY_PROPERTYID_OREDERNUMB);
+ }
else
+ {
findValueByPropertyIdOrderNumber.clearParameters();
+ }
findValueByPropertyIdOrderNumber.setString(1, cid);
findValueByPropertyIdOrderNumber.setInt(2, orderNumb);
@@ -571,9 +574,13 @@
protected int renameNode(NodeData data) throws SQLException
{
if (renameNode == null)
+ {
renameNode = dbConnection.prepareStatement(RENAME_NODE);
+ }
else
+ {
renameNode.clearParameters();
+ }
renameNode.setString(1, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID : getInternalId(data
.getParentIdentifier()));
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBConnectionFactory.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBConnectionFactory.java 2010-01-20 12:41:55 UTC (rev 1503)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBConnectionFactory.java 2010-01-20 12:46:45 UTC (rev 1504)
@@ -32,7 +32,7 @@
* 26.08.2009
*
* @author <a href="mailto:dezder at bk.ru">Denis Grebenyuk</a>
- * @version $Id:$
+ * @version $Id$
*/
public class HSQLDBConnectionFactory extends GenericCQConnectionFactory
{
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java 2010-01-20 12:41:55 UTC (rev 1503)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java 2010-01-20 12:46:45 UTC (rev 1504)
@@ -29,7 +29,7 @@
* 26.08.2009
*
* @author <a href="mailto:dezder at bk.ru">Denis Grebenyuk</a>
- * @version $Id:$
+ * @version $Id$
*/
public class HSQLDBMultiDbJDBCConnection extends MultiDbJDBCConnection
{
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java 2010-01-20 12:41:55 UTC (rev 1503)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java 2010-01-20 12:46:45 UTC (rev 1504)
@@ -30,7 +30,7 @@
* 26.08.2009
*
* @author <a href="mailto:dezder at bk.ru">Denis Grebenyuk</a>
- * @version $Id:$
+ * @version $Id$
*/
public class HSQLDBSingleDbJDBCConnection extends SingleDbJDBCConnection
{
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2010-01-20 12:41:55 UTC (rev 1503)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2010-01-20 12:46:45 UTC (rev 1504)
@@ -75,7 +75,6 @@
protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
- @Deprecated
protected PreparedStatement findValueByPropertyIdOrderNumber;
protected PreparedStatement findNodesByParentId;
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2010-01-20 12:41:55 UTC (rev 1503)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2010-01-20 12:46:45 UTC (rev 1504)
@@ -587,13 +587,16 @@
/**
* {@inheritDoc}
*/
- @Deprecated
protected ResultSet findValueByPropertyIdOrderNumber(String cid, int orderNumb) throws SQLException
{
if (findValueByPropertyIdOrderNumber == null)
+ {
findValueByPropertyIdOrderNumber = dbConnection.prepareStatement(FIND_VALUE_BY_PROPERTYID_OREDERNUMB);
+ }
else
+ {
findValueByPropertyIdOrderNumber.clearParameters();
+ }
findValueByPropertyIdOrderNumber.setString(1, cid);
findValueByPropertyIdOrderNumber.setInt(2, orderNumb);
More information about the exo-jcr-commits
mailing list