exo-jcr SVN: r3407 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2010-11-08 08:17:47 -0500 (Mon, 08 Nov 2010)
New Revision: 3407
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java
Log:
EXOJCR-1038: "Some Unit Tests on DB2 related to the CAS plugin fail" fixed db2 error message parsing in accordance to a new driver
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java 2010-11-08 09:53:44 UTC (rev 3406)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java 2010-11-08 13:17:47 UTC (rev 3407)
@@ -100,7 +100,7 @@
* %s must be replaced with original table name before compile Pattern.
*/
private static final String DB2_PK_CONSTRAINT_DETECT_PATTERN =
- "(.*DB2 SQL [Ee]rror+.*SQLCODE[:=].?-803+.*SQLSTATE[:=].?23505+.*JCR_VCAS_TEST.*)+?";
+ "(.*DB2 SQL [Ee]rror+.*SQLCODE[:=].?-803+.*SQLSTATE[:=].?23505+.*%s.*)+?";
/**
* MYSQL_PK_CONSTRAINT_DETECT_PATTERN.
13 years, 6 months
exo-jcr SVN: r3406 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2010-11-08 04:53:44 -0500 (Mon, 08 Nov 2010)
New Revision: 3406
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java
Log:
EXOJCR-1038: "Some Unit Tests on DB2 related to the CAS plugin fail" fixed db2 error message parsing in accordance to a new driver
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java 2010-11-08 08:43:42 UTC (rev 3405)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java 2010-11-08 09:53:44 UTC (rev 3406)
@@ -100,7 +100,7 @@
* %s must be replaced with original table name before compile Pattern.
*/
private static final String DB2_PK_CONSTRAINT_DETECT_PATTERN =
- "(.*DB2 SQL error+.*SQLCODE: -803+.*SQLSTATE: 23505+.*%s.*)+?";
+ "(.*DB2 SQL [Ee]rror+.*SQLCODE[:=].?-803+.*SQLSTATE[:=].?23505+.*JCR_VCAS_TEST.*)+?";
/**
* MYSQL_PK_CONSTRAINT_DETECT_PATTERN.
13 years, 6 months
exo-jcr SVN: r3405 - ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/header.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2010-11-08 03:43:42 -0500 (Mon, 08 Nov 2010)
New Revision: 3405
Modified:
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/header/HeaderHelper.java
Log:
EXOJCR-1037
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/header/HeaderHelper.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/header/HeaderHelper.java 2010-11-08 07:42:28 UTC (rev 3404)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/header/HeaderHelper.java 2010-11-08 08:43:42 UTC (rev 3405)
@@ -90,14 +90,15 @@
/**
* Comparator for tokens which have quality value.
- * @see QualityValue
+ *
+ * @see QualityValue
*/
public static final Comparator<QualityValue> QUALITY_VALUE_COMPARATOR = new Comparator<QualityValue>()
{
/**
* Compare two QualityValue for order.
- *
+ *
* @param o1 first QualityValue to be compared
* @param o2 second QualityValue to be compared
* @return result of comparison
@@ -121,6 +122,7 @@
/**
* Accept media type producer.
+ *
* @see ListHeaderProducer
*/
private static final ListHeaderProducer<AcceptMediaType> LIST_MEDIA_TYPE_PRODUCER =
@@ -140,7 +142,7 @@
/**
* Create sorted by quality value accepted media type list.
- *
+ *
* @param header source header string
* @return List of AcceptMediaType
*/
@@ -154,6 +156,7 @@
/**
* Accept language producer.
+ *
* @see ListHeaderProducer
*/
private static final ListHeaderProducer<AcceptLanguage> LIST_LANGUAGE_PRODUCER =
@@ -173,7 +176,7 @@
/**
* Create sorted by quality value accepted language list.
- *
+ *
* @param header source header string
* @return List of AcceptLanguage
*/
@@ -186,8 +189,9 @@
}
/**
- * Accept token producer. Useful for processing
- * 'accept-charset' and 'accept-encoding' request headers.
+ * Accept token producer. Useful for processing 'accept-charset' and
+ * 'accept-encoding' request headers.
+ *
* @see ListHeaderProducer
*/
private static final ListHeaderProducer<AcceptToken> LIST_TOKEN_PRODUCER = new ListHeaderProducer<AcceptToken>()
@@ -226,7 +230,7 @@
/**
* Create sorted by quality value 'accept-character' list.
- *
+ *
* @param header source header string
* @return List of accept charset tokens
*/
@@ -240,7 +244,7 @@
/**
* Create sorted by quality value 'accept-encoding' list.
- *
+ *
* @param header source header string
* @return List of accept encoding tokens
*/
@@ -261,7 +265,7 @@
{
/**
- * Cookie name.
+ * Cookie name.
*/
String name;
@@ -322,7 +326,7 @@
/**
* Parse cookie header string and create collection of cookie from it.
- *
+ *
* @param cookie the cookie string.
* @return collection of Cookie.
*/
@@ -366,7 +370,7 @@
if (name.indexOf('$') == -1)
{
- // first save previous cookie
+ // first save previous cookie
if (temp != null)
l.add(new Cookie(temp.name, temp.value, temp.path, temp.domain, temp.version));
@@ -462,10 +466,10 @@
/**
* Parse date header. Will try to found appropriated format for given date
- * header. Format can be one of see {@link <a
- * href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1"
- * >HTTP/1.1 documentation</a>}.
- *
+ * header. Format can be one of see
+ * {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1" >HTTP/1.1 documentation</a>}
+ * .
+ *
* @param header source date header
* @return parsed Date
*/
@@ -478,9 +482,9 @@
}
catch (ParseException e)
{
- // ignore all ParseException now
+ // ignore all ParseException now
}
- // no one format was found
+ // no one format was found
throw new IllegalArgumentException("Not found appropriated date format for " + header);
}
@@ -488,7 +492,8 @@
/**
* @param httpHeaders HTTP headers
- * @return parsed content-length or null if content-length header is not specified
+ * @return parsed content-length or null if content-length header is not
+ * specified
*/
public static long getContentLengthLong(MultivaluedMap<String, String> httpHeaders)
{
@@ -500,7 +505,7 @@
/**
* Create string representation of Java Object for adding to response. Method
* use {@link HeaderDelegate#toString()}.
- *
+ *
* @param o HTTP header as Java type.
* @return string representation of supplied type
*/
@@ -508,14 +513,14 @@
public static String getHeaderAsString(Object o)
{
HeaderDelegate hd = RuntimeDelegate.getInstance().createHeaderDelegate(o.getClass());
- return hd.toString(o);
+ return hd != null ? hd.toString(o) : o.toString();
}
/**
- * Convert Collection<String> to single String, where values separated by ','.
- * Useful for getting source string of HTTP header for next processing quality
- * value of header tokens.
- *
+ * Convert Collection<String> to single String, where values separated
+ * by ','. Useful for getting source string of HTTP header for next
+ * processing quality value of header tokens.
+ *
* @param collection the source list
* @return String result
*/
@@ -540,7 +545,7 @@
/**
* Append string in given string buffer, if string contains quotes or
* whitespace, then it be escaped.
- *
+ *
* @param sb string buffer
* @param s string
*/
@@ -564,7 +569,7 @@
/**
* Append string in given string buffer, quotes will be escaped.
- *
+ *
* @param sb string buffer
* @param s string
*/
@@ -581,7 +586,7 @@
/**
* Remove all whitespace from given string.
- *
+ *
* @param s the source string
* @return the result string
*/
@@ -597,7 +602,7 @@
/**
* Add quotes to <code>String</code> if it consists whitespaces, otherwise
* <code>String</code> will be returned without changes.
- *
+ *
* @param s the source string.
* @return new string.
*/
@@ -614,7 +619,7 @@
/**
* Check syntax of quality value and parse it. Quality value must have not
* more then 5 characters and be not more then 1 .
- *
+ *
* @param qstring string representation of quality value
* @return quality value
*/
@@ -633,7 +638,7 @@
/**
* Check is given string token. Token may contains only US-ASCII characters
* except separators, {@link #SEPARTORS} and controls.
- *
+ *
* @param token the token
* @return -1 if string has only valid character otherwise index of first
* wrong character
@@ -654,7 +659,7 @@
* The cookies parameters can be separated by ';' or ',', try to find first
* available separator in cookie string. If both not found the string length
* will be returned.
- *
+ *
* @param cookie the cookie string.
* @param start index for start searching.
* @return the index of ',' or ';'.
@@ -683,7 +688,7 @@
* <p>
* String \"hello \\\"someone\\\"\" will be changed to hello \"someone\"
* </p>
- *
+ *
* @param token token for processing
* @return result
*/
13 years, 6 months
exo-jcr SVN: r3403 - jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-11-05 12:29:16 -0400 (Fri, 05 Nov 2010)
New Revision: 3403
Modified:
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
Log:
EXOJCR-1006: allow to keep missing values into the JCR cache based on JBossCache
Modified: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-11-05 15:33:42 UTC (rev 3402)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-11-05 16:29:16 UTC (rev 3403)
@@ -31,6 +31,7 @@
import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.NullItemData;
+import org.exoplatform.services.jcr.datamodel.NullNodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -58,6 +59,7 @@
import java.util.Set;
import javax.jcr.RepositoryException;
+import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
/**
@@ -187,7 +189,7 @@
do
{
String itemId = (String)cache.get(makeChildFqn(root, parentId, (String)childs.next()), ITEM_ID);
- if (itemId != null)
+ if (itemId != null && !itemId.equals(NullItemData.NULL_ID))
{
n = (T)cache.get(makeItemFqn(itemId), ITEM_DATA);
}
@@ -387,10 +389,10 @@
*/
public void put(ItemData item)
{
- // TODO its temporary
+ // There is different commit processing for NullNodeData and ordinary ItemData
if (item instanceof NullItemData)
{
- // skip null values
+ putNullItem((NullItemData)item);
return;
}
@@ -583,17 +585,6 @@
public void addChildPropertiesList(NodeData parent, List<PropertyData> childProperties)
{
// TODO not implemented, will force read from DB
- // try
- // {
- // cache.beginTransaction();
- // cache.setLocal(true);
- //
- // }
- // finally
- // {
- // cache.setLocal(false);
- // cache.commitTransaction();
- // }
}
/**
@@ -610,24 +601,46 @@
public ItemData get(String parentId, QPathEntry name, ItemType itemType)
{
String itemId = null;
- if (itemType == ItemType.NODE || itemType == ItemType.UNKNOWN)
+
+ if (itemType == ItemType.UNKNOWN)
{
- // try as node first
+ // Try as node first.
itemId = (String)cache.get(makeChildFqn(childNodes, parentId, name), ITEM_ID);
+
+ if (itemId == null || itemId.equals(NullItemData.NULL_ID))
+ {
+ // node with such a name is not found or marked as not-exist, so check the properties
+ String propId = (String)cache.get(makeChildFqn(childProps, parentId, name), ITEM_ID);
+ if (propId != null)
+ {
+ itemId = propId;
+ }
+ }
}
-
- if (itemType == ItemType.PROPERTY || itemType == ItemType.UNKNOWN && itemId == null)
+ else if (itemType == ItemType.NODE)
{
- // try as property
+ itemId = (String)cache.get(makeChildFqn(childNodes, parentId, name), ITEM_ID);
+ }
+ else
+ {
itemId = (String)cache.get(makeChildFqn(childProps, parentId, name), ITEM_ID);
}
if (itemId != null)
{
- return get(itemId);
+ if (itemId.equals(NullItemData.NULL_ID))
+ {
+ // this NullNodeData object will not be placed at cache, so we can use unsafe constructor
+ return new NullNodeData(parentId, name);
+ }
+ else
+ {
+ return get(itemId);
+ }
}
return null;
+
}
/**
@@ -653,7 +666,7 @@
for (Object child : set)
{
NodeData node = (NodeData)cache.get(makeItemFqn((String)child), ITEM_DATA);
- if (node == null)
+ if (node == null || node instanceof NullItemData)
{
return null;
}
@@ -718,7 +731,7 @@
for (Object child : set)
{
PropertyData prop = (PropertyData)cache.get(makeItemFqn((String)child), ITEM_DATA);
- if (prop == null)
+ if (prop == null || prop instanceof NullItemData)
{
return null;
}
@@ -861,9 +874,60 @@
}
// add in ITEMS
- return (ItemData)cache.put(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
+ // NullNodeData must never be returned inside internal cache operations.
+ ItemData returnedData = (ItemData)cache.putInBuffer(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
+ return (returnedData instanceof NullItemData) ? null : returnedData;
+
}
+ /**
+ * Internal put NullNode.
+ *
+ * @param node, NodeData, new data to put in the cache
+ */
+ protected void putNullItem(NullItemData node)
+ {
+ boolean inTransaction = cache.isTransactionActive();
+ try
+ {
+ if (!inTransaction)
+ {
+ cache.beginTransaction();
+ }
+ cache.setLocal(true);
+
+ if (node.getQPath() == null)
+ {
+ //put in $ITEMS
+ cache.put(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
+ }
+ else
+ {
+ if (node.isNode())
+ {
+ // put in $CHILD_NODES
+ cache.put(makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node
+ .getQPath().getEntries().length - 1]), ITEM_ID, node.getIdentifier());
+ }
+ else
+ {
+ // put in $CHILD_PROPERTIES
+ cache.put(makeChildFqn(childProps, node.getParentIdentifier(), node.getQPath().getEntries()[node
+ .getQPath().getEntries().length - 1]), ITEM_ID, node.getIdentifier());
+ }
+ }
+ }
+ finally
+ {
+ cache.setLocal(false);
+ if (!inTransaction)
+ {
+ dedicatedTxCommit();
+ }
+ }
+
+ }
+
protected ItemData putNodeInBufferedCache(NodeData node, ModifyChildOption modifyListsOfChild)
{
// if not a root node
@@ -882,7 +946,9 @@
}
}
// add in ITEMS
- return (ItemData)cache.putInBuffer(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
+ // NullNodeData must never be returned inside internal cache operations.
+ ItemData returnedData = (ItemData)cache.putInBuffer(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
+ return (returnedData instanceof NullItemData) ? null : returnedData;
}
/**
@@ -904,7 +970,9 @@
cache.addToList(makeChildListFqn(childPropsList, prop.getParentIdentifier()), ITEM_LIST, prop.getIdentifier());
}
// add in ITEMS
- return (PropertyData)cache.put(makeItemFqn(prop.getIdentifier()), ITEM_DATA, prop);
+ // NullItemData must never be returned inside internal cache operations.
+ ItemData returnedData = (ItemData)cache.put(makeItemFqn(prop.getIdentifier()), ITEM_DATA, prop);
+ return (returnedData instanceof NullItemData) ? null : (PropertyData)returnedData;
}
protected void removeItem(ItemData item)
@@ -958,18 +1026,22 @@
protected void updateMixin(NodeData node)
{
NodeData prevData = (NodeData)cache.put(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
- if (prevData != null)
+ // prevent update NullNodeData
+ if (!(prevData instanceof NullItemData))
{
- // do update ACL if needed
- if (prevData.getACL() == null || !prevData.getACL().equals(node.getACL()))
+ if (prevData != null)
{
- updateChildsACL(node.getIdentifier(), node.getACL());
+ // do update ACL if needed
+ if (prevData.getACL() == null || !prevData.getACL().equals(node.getACL()))
+ {
+ updateChildsACL(node.getIdentifier(), node.getACL());
+ }
}
+ else if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Previous NodeData not found for mixin update " + node.getQPath().getAsString());
+ }
}
- else if (LOG.isDebugEnabled())
- {
- LOG.debug("Previous NodeData not found for mixin update " + node.getQPath().getAsString());
- }
}
/**
@@ -1058,7 +1130,8 @@
// check is this descendant of prevRootPath
QPath nodeQPath = data.getQPath();
- if (nodeQPath.isDescendantOf(prevRootPath))
+ // NullNodeData's qPath==null;
+ if (nodeQPath != null && nodeQPath.isDescendantOf(prevRootPath))
{
//make relative path
@@ -1224,4 +1297,44 @@
NOT_MODIFY, MODIFY, FORCE_MODIFY
}
+ /**
+ * Allows to commit the cache changes in a dedicated XA Tx in order to avoid potential
+ * deadlocks
+ */
+ private void dedicatedTxCommit()
+ {
+ // Ensure that the commit is done in a dedicated tx to avoid deadlock due
+ // to global XA Tx
+ TransactionManager tm = getTransactionManager();
+ Transaction tx = null;
+ try
+ {
+ if (tm != null)
+ {
+ try
+ {
+ tx = tm.suspend();
+ }
+ catch (Exception e)
+ {
+ LOG.warn("Cannot suspend the current transaction", e);
+ }
+ }
+ cache.commitTransaction();
+ }
+ finally
+ {
+ if (tx != null)
+ {
+ try
+ {
+ tm.resume(tx);
+ }
+ catch (Exception e)
+ {
+ LOG.warn("Cannot resume the current transaction", e);
+ }
+ }
+ }
+ }
}
13 years, 6 months
exo-jcr SVN: r3402 - in jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr: impl/dataflow/persistent and 2 other directories.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-11-05 11:33:42 -0400 (Fri, 05 Nov 2010)
New Revision: 3402
Added:
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullItemData.java
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullNodeData.java
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullPropertyData.java
Modified:
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java
jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
Log:
EXOJCR-1006: allow to keep missing values into the JCR cache based on ISPN
Added: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullItemData.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullItemData.java (rev 0)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullItemData.java 2010-11-05 15:33:42 UTC (rev 3402)
@@ -0,0 +1,93 @@
+/*
+ * 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.datamodel;
+
+import org.exoplatform.services.jcr.dataflow.ItemDataVisitor;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: NullItemData.java 111 2008-11-11 11:11:11Z serg $
+ */
+public abstract class NullItemData implements ItemData
+{
+
+ public static final String NULL_ID = "_null_id";
+
+ private final String id;
+
+ private final String parentId;
+
+ private final QPath path;
+
+ public NullItemData(NodeData parentData, QPathEntry name)
+ {
+ this.parentId = parentData.getIdentifier();
+ this.path = QPath.makeChildPath(parentData.getQPath(), name);
+ this.id = NULL_ID;
+ }
+
+ /**
+ * This constructor must never be used for null nodes placed in cache. Only for returned values.
+ *
+ * @param parentId
+ * @param name
+ */
+ public NullItemData(String parentId, QPathEntry name)
+ {
+ this.parentId = parentId;
+ this.path = null;
+ this.id = NULL_ID;
+ }
+
+ public NullItemData(String id)
+ {
+ this.parentId = null;
+ this.path = null;
+ this.id = id;
+ }
+
+ public void accept(ItemDataVisitor visitor) throws RepositoryException
+ {
+ }
+
+ public String getIdentifier()
+ {
+ return id;
+ }
+
+ public String getParentIdentifier()
+ {
+ return parentId;
+ }
+
+ public int getPersistedVersion()
+ {
+ return 0;
+ }
+
+ public QPath getQPath()
+ {
+ return path;
+ }
+
+}
Added: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullNodeData.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullNodeData.java (rev 0)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullNodeData.java 2010-11-05 15:33:42 UTC (rev 3402)
@@ -0,0 +1,93 @@
+/*
+ * 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.jcr.datamodel;
+
+import org.exoplatform.services.jcr.access.AccessControlList;
+
+/**
+ * This class is used to represent <code>null</code> value, it is designed to be used
+ * into the cache to represent missing value.
+ *
+ * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
+ * @version $Id: NullNodeData.java 111 2010-11-11 11:11:11Z tolusha $
+ */
+public class NullNodeData extends NullItemData implements NodeData
+{
+ public NullNodeData(NodeData parentData, QPathEntry name)
+ {
+ super(parentData, name);
+ }
+
+ /**
+ * This constructor must never be used for null nodes placed in cache. Only for returned values.
+ *
+ * @param parentId
+ * @param name
+ */
+ public NullNodeData(String parentId, QPathEntry name)
+ {
+ super(parentId, name);
+ }
+
+ public NullNodeData(String id)
+ {
+ super(id);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isNode()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public AccessControlList getACL()
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public InternalQName[] getMixinTypeNames()
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getOrderNumber()
+ {
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public InternalQName getPrimaryTypeName()
+ {
+ return null;
+ }
+
+}
Added: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullPropertyData.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullPropertyData.java (rev 0)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullPropertyData.java 2010-11-05 15:33:42 UTC (rev 3402)
@@ -0,0 +1,74 @@
+/*
+ * 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.datamodel;
+
+import java.util.List;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: NullPropertyData.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class NullPropertyData extends NullItemData implements PropertyData
+{
+
+ public NullPropertyData(NodeData parentData, QPathEntry name)
+ {
+ super(parentData, name);
+ }
+
+ public NullPropertyData(String id)
+ {
+ super(id);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getType()
+ {
+ return -1;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<ValueData> getValues()
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isMultiValued()
+ {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isNode()
+ {
+ return false;
+ }
+
+}
Modified: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-11-05 10:46:02 UTC (rev 3401)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-11-05 15:33:42 UTC (rev 3402)
@@ -23,6 +23,9 @@
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.NullItemData;
+import org.exoplatform.services.jcr.datamodel.NullNodeData;
+import org.exoplatform.services.jcr.datamodel.NullPropertyData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.datamodel.ValueData;
@@ -410,18 +413,20 @@
{
data = getPersistedItemData(parentData, name, itemType);
}
- else if (!data.isNode())
- {
- fixPropertyValues((PropertyData)data);
- }
}
finally
{
request.done();
}
}
- else if (!data.isNode())
+
+ if (data instanceof NullItemData)
{
+ return null;
+ }
+
+ if (data != null && !data.isNode())
+ {
fixPropertyValues((PropertyData)data);
}
@@ -452,18 +457,20 @@
{
data = getPersistedItemData(identifier);
}
- else if (!data.isNode())
- {
- fixPropertyValues((PropertyData)data);
- }
}
finally
{
request.done();
}
}
- else if (!data.isNode())
+
+ if (data instanceof NullItemData)
{
+ return null;
+ }
+
+ if (data != null && !data.isNode())
+ {
fixPropertyValues((PropertyData)data);
}
@@ -676,11 +683,26 @@
throws RepositoryException
{
ItemData data = super.getItemData(parentData, name, itemType);
- if (data != null && cache.isEnabled())
+ if (cache.isEnabled())
{
- cache.put(data);
+ if (data == null)
+ {
+ if (itemType == ItemType.NODE || itemType == ItemType.UNKNOWN)
+ {
+ cache.put(new NullNodeData(parentData, name));
+ }
+ else
+ {
+ cache.put(new NullPropertyData(parentData, name));
+ }
+ }
+ else
+ {
+ cache.put(data);
+ }
}
return data;
+
}
/**
@@ -693,9 +715,17 @@
protected ItemData getPersistedItemData(String identifier) throws RepositoryException
{
ItemData data = super.getItemData(identifier);
- if (data != null && cache.isEnabled())
+ if (cache.isEnabled())
{
- cache.put(data);
+ if (data != null)
+ {
+ cache.put(data);
+ }
+ else if (identifier != null)
+ {
+ // no matter does property or node expected - store NullNodeData
+ cache.put(new NullNodeData(identifier));
+ }
}
return data;
}
Modified: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java 2010-11-05 10:46:02 UTC (rev 3401)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java 2010-11-05 15:33:42 UTC (rev 3402)
@@ -27,6 +27,7 @@
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.NullItemData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -42,10 +43,10 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Timer;
import java.util.TimerTask;
import java.util.WeakHashMap;
+import java.util.Map.Entry;
import java.util.concurrent.Semaphore;
import java.util.concurrent.locks.ReentrantLock;
@@ -938,6 +939,12 @@
if (enabled && item != null)
{
+ if (item instanceof NullItemData)
+ {
+ // skip null values
+ return;
+ }
+
writeLock.lock();
try
{
@@ -1071,7 +1078,7 @@
{
if (enabled && parentData != null && childItems != null)
{ // TODO don't check parentData !=
- // null && childItems != null
+ // null && childItems != null
String logInfo = null;
if (LOG.isDebugEnabled())
@@ -1133,7 +1140,7 @@
{
if (enabled && parentData != null && childItems != null)
{ // TODO don't check parentData !=
- // null && childItems != null
+ // null && childItems != null
String logInfo = null;
if (LOG.isDebugEnabled())
@@ -1184,7 +1191,7 @@
{
if (enabled && parentData != null && childItems != null)
{ // TODO don't check parentData !=
- // null && childItems != null
+ // null && childItems != null
String logInfo = null;
if (LOG.isDebugEnabled())
@@ -1662,7 +1669,8 @@
{
writeLock.unlock();
}
- LOG.info(name + " : set liveTime=" + liveTime + "ms. New value will be applied to items cached from this moment.");
+ LOG
+ .info(name + " : set liveTime=" + liveTime + "ms. New value will be applied to items cached from this moment.");
}
/**
Modified: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java 2010-11-05 10:46:02 UTC (rev 3401)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java 2010-11-05 15:33:42 UTC (rev 3402)
@@ -28,6 +28,7 @@
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.NullItemData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -157,18 +158,22 @@
{
// from cache at first
ItemData cdata = persistentManager.getCachedItemData(identifier);
- if (cdata != null)
+ if (cdata != null && !(cdata instanceof NullItemData))
+ {
return super.getItemData(identifier);
+ }
if (!this.equals(versionDataManager) && !identifier.equals(Constants.ROOT_UUID))
{
// search in System cache for /jcr:system nodes only
cdata = versionDataManager.persistentManager.getCachedItemData(identifier);
- if (cdata != null)
+ if (cdata != null && !(cdata instanceof NullItemData))
+ {
if (isSystemDescendant(cdata.getQPath()))
return versionDataManager.getItemData(identifier);
else
return null;
+ }
}
// then from persistence
Modified: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java 2010-11-05 10:46:02 UTC (rev 3401)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java 2010-11-05 15:33:42 UTC (rev 3402)
@@ -39,6 +39,8 @@
import java.util.Set;
import java.util.concurrent.TimeUnit;
+import javax.transaction.TransactionManager;
+
/**
* Decorator over the Infinispan Cache that stores changes in buffer, then sorts and applies it.
*
@@ -744,7 +746,7 @@
return withReturnValue ? parentCache.get(key) : null;
}
-
+
/**
* {@inheritDoc}
*/
@@ -919,6 +921,11 @@
return changesContainer;
}
+ public TransactionManager getTransactionManager()
+ {
+ return parentCache.getTransactionManager();
+ }
+
/**
*
* @param key
Modified: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java 2010-11-05 10:46:02 UTC (rev 3401)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java 2010-11-05 15:33:42 UTC (rev 3402)
@@ -31,6 +31,9 @@
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.NullItemData;
+import org.exoplatform.services.jcr.datamodel.NullNodeData;
+import org.exoplatform.services.jcr.datamodel.NullPropertyData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -53,6 +56,8 @@
import java.util.Set;
import javax.jcr.RepositoryException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
/**
* Created by The eXo Platform SAS.<p/>
@@ -87,7 +92,6 @@
*/
class NodesOrderComparator<N extends NodeData> implements Comparator<NodeData>
{
-
/**
* {@inheritDoc}
*/
@@ -229,6 +233,13 @@
*/
public void put(ItemData item)
{
+ // There is different commit processing for NullNodeData and ordinary ItemData.
+ if (item instanceof NullItemData)
+ {
+ putNullItem((NullItemData)item);
+ return;
+ }
+
boolean inTransaction = cache.isTransactionActive();
try
{
@@ -434,20 +445,45 @@
*/
public ItemData get(String parentIdentifier, QPathEntry name, ItemType itemType)
{
- String id = null;
- if (itemType == ItemType.NODE || itemType == ItemType.UNKNOWN)
+ String itemId = null;
+
+ if (itemType == ItemType.UNKNOWN)
{
- // try as node first
- id = (String)cache.get(new CacheQPath(parentIdentifier, name, ItemType.NODE));
+ // Try as node first.
+ itemId = (String)cache.get(new CacheQPath(parentIdentifier, name, ItemType.NODE));
+
+ if (itemId == null || itemId.equals(NullItemData.NULL_ID))
+ {
+ // node with such a name is not found or marked as not-exist, so check the properties
+ String propId = (String)cache.get(new CacheQPath(parentIdentifier, name, ItemType.PROPERTY));
+ if (propId != null)
+ {
+ itemId = propId;
+ }
+ }
}
+ else if (itemType == ItemType.NODE)
+ {
+ itemId = (String)cache.get(new CacheQPath(parentIdentifier, name, ItemType.NODE));;
+ }
+ else
+ {
+ itemId = (String)cache.get(new CacheQPath(parentIdentifier, name, ItemType.PROPERTY));;
+ }
- if (itemType == ItemType.PROPERTY || itemType == ItemType.UNKNOWN && id == null)
+ if (itemId != null)
{
- // try as property
- id = (String)cache.get(new CacheQPath(parentIdentifier, name, ItemType.PROPERTY));
+ if (itemId.equals(NullItemData.NULL_ID))
+ {
+ // this NullNodeData object will not be placed at cache, so we can use unsafe constructor
+ return new NullNodeData(parentIdentifier, name);
+ }
+ else
+ {
+ return get(itemId);
+ }
}
-
- return get(id);
+ return null;
}
/**
@@ -638,10 +674,50 @@
}
}
- return (ItemData)cache.putInBuffer(new CacheId(node.getIdentifier()), node);
+ // NullNodeData must never be returned inside internal cache operations.
+ ItemData itemData = (ItemData)cache.putInBuffer(new CacheId(node.getIdentifier()), node);
+ return (itemData instanceof NullItemData) ? null : itemData;
}
/**
+ * Internal put NullNode.
+ *
+ * @param node, NodeData, new data to put in the cache
+ */
+ protected void putNullItem(NullItemData node)
+ {
+ boolean inTransaction = cache.isTransactionActive();
+ try
+ {
+ if (!inTransaction)
+ {
+ cache.beginTransaction();
+ }
+ cache.setLocal(true);
+
+ if (node.getQPath() == null)
+ {
+ //put in $ITEMS
+ cache.put(new CacheId(node.getIdentifier()), node);
+ }
+ else
+ {
+
+ cache.put(new CacheQPath(node.getParentIdentifier(), node.getQPath(), (node.isNode() ? ItemType.NODE
+ : ItemType.PROPERTY)), node.getIdentifier());
+ }
+ }
+ finally
+ {
+ cache.setLocal(false);
+ if (!inTransaction)
+ {
+ dedicatedTxCommit();
+ }
+ }
+ }
+
+ /**
* Internal put Property.
*
* @param node, PropertyData, new data to put in the cache
@@ -657,7 +733,10 @@
}
cache.put(new CacheQPath(prop.getParentIdentifier(), prop.getQPath(), ItemType.PROPERTY), prop.getIdentifier());
- return (PropertyData)cache.put(new CacheId(prop.getIdentifier()), prop, true);
+
+ // NullItemData must never be returned inside internal cache operations.
+ PropertyData propData = (PropertyData)cache.put(new CacheId(prop.getIdentifier()), prop, true);
+ return (propData instanceof NullPropertyData) ? null : propData;
}
protected void removeItem(ItemData item)
@@ -689,19 +768,22 @@
protected void updateMixin(NodeData node)
{
NodeData prevData = (NodeData)cache.put(new CacheId(node.getIdentifier()), node, true);
-
- if (prevData != null)
+ // prevent update NullNodeData
+ if (!(prevData instanceof NullNodeData))
{
- // do update ACL if needed
- if (prevData.getACL() == null || !prevData.getACL().equals(node.getACL()))
+ if (prevData != null)
{
- updateChildsACL(node.getIdentifier(), node.getACL());
+ // do update ACL if needed
+ if (prevData.getACL() == null || !prevData.getACL().equals(node.getACL()))
+ {
+ updateChildsACL(node.getIdentifier(), node.getACL());
+ }
}
+ else if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Previous NodeData not found for mixin update " + node.getQPath().getAsString());
+ }
}
- else if (LOG.isDebugEnabled())
- {
- LOG.debug("Previous NodeData not found for mixin update " + node.getQPath().getAsString());
- }
}
/**
@@ -714,6 +796,7 @@
*/
protected void updateInBuffer(final NodeData node, final NodeData prevNode)
{
+ // I expect that NullNodeData will never update existing NodeData.
CacheQPath prevKey = new CacheQPath(node.getParentIdentifier(), prevNode.getQPath(), ItemType.NODE);
if (node.getIdentifier().equals(cache.getFromBuffer(prevKey)))
{
@@ -755,7 +838,8 @@
{
// check is this descendant of prevRootPath
QPath nodeQPath = data.getQPath();
- if (nodeQPath.isDescendantOf(prevRootPath))
+ // NullNodeData's qPath==null;
+ if (nodeQPath != null && nodeQPath.isDescendantOf(prevRootPath))
{
//make relative path
@@ -878,4 +962,45 @@
NOT_MODIFY, MODIFY, FORCE_MODIFY
}
+ /**
+ * Allows to commit the cache changes in a dedicated XA Tx in order to avoid potential
+ * deadlocks
+ */
+ private void dedicatedTxCommit()
+ {
+ // Ensure that the commit is done in a dedicated tx to avoid deadlock due
+ // to global XA Tx
+ TransactionManager tm = cache.getTransactionManager();
+ Transaction tx = null;
+ try
+ {
+ if (tm != null)
+ {
+ try
+ {
+ tx = tm.suspend();
+ }
+ catch (Exception e)
+ {
+ LOG.warn("Cannot suspend the current transaction", e);
+ }
+ }
+ cache.commitTransaction();
+ }
+ finally
+ {
+ if (tx != null)
+ {
+ try
+ {
+ tm.resume(tx);
+ }
+ catch (Exception e)
+ {
+ LOG.warn("Cannot resume the current transaction", e);
+ }
+ }
+ }
+ }
+
}
Modified: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-11-05 10:46:02 UTC (rev 3401)
+++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-11-05 15:33:42 UTC (rev 3402)
@@ -30,6 +30,7 @@
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.NullItemData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -386,6 +387,13 @@
*/
public void put(ItemData item)
{
+ // TODO its temporary
+ if (item instanceof NullItemData)
+ {
+ // skip null values
+ return;
+ }
+
boolean inTransaction = cache.isTransactionActive();
try
{
@@ -840,16 +848,15 @@
if (node.getParentIdentifier() != null)
{
// add in CHILD_NODES
- cache.put(
- makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node.getQPath()
- .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
+ cache.put(makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node.getQPath()
+ .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
// if MODIFY and List present OR FORCE_MODIFY, then write
- if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childNodesList,
- node.getParentIdentifier())) != null)
+ if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childNodesList, node
+ .getParentIdentifier())) != null)
|| modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
{
- cache.addToList(makeChildListFqn(childNodesList, node.getParentIdentifier()), ITEM_LIST,
- node.getIdentifier());
+ cache.addToList(makeChildListFqn(childNodesList, node.getParentIdentifier()), ITEM_LIST, node
+ .getIdentifier());
}
}
@@ -863,16 +870,15 @@
if (node.getParentIdentifier() != null)
{
// add in CHILD_NODES
- cache.put(
- makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node.getQPath()
- .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
+ cache.put(makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node.getQPath()
+ .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
// if MODIFY and List present OR FORCE_MODIFY, then write
- if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childNodesList,
- node.getParentIdentifier())) != null)
+ if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childNodesList, node
+ .getParentIdentifier())) != null)
|| modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
{
- cache.addToList(makeChildListFqn(childNodesList, node.getParentIdentifier()), ITEM_LIST,
- node.getIdentifier());
+ cache.addToList(makeChildListFqn(childNodesList, node.getParentIdentifier()), ITEM_LIST, node
+ .getIdentifier());
}
}
// add in ITEMS
@@ -888,12 +894,11 @@
protected PropertyData putProperty(PropertyData prop, ModifyChildOption modifyListsOfChild)
{
// add in CHILD_PROPS
- cache.put(
- makeChildFqn(childProps, prop.getParentIdentifier(),
- prop.getQPath().getEntries()[prop.getQPath().getEntries().length - 1]), ITEM_ID, prop.getIdentifier());
+ cache.put(makeChildFqn(childProps, prop.getParentIdentifier(), prop.getQPath().getEntries()[prop.getQPath()
+ .getEntries().length - 1]), ITEM_ID, prop.getIdentifier());
// if MODIFY and List present OR FORCE_MODIFY, then write
- if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childPropsList,
- prop.getParentIdentifier())) != null)
+ if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childPropsList, prop
+ .getParentIdentifier())) != null)
|| modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
{
cache.addToList(makeChildListFqn(childPropsList, prop.getParentIdentifier()), ITEM_LIST, prop.getIdentifier());
@@ -915,8 +920,8 @@
.getQPath().getEntries().length - 1]));
// remove from CHILD_NODES_LIST of parent
- cache.removeFromList(makeChildListFqn(childNodesList, item.getParentIdentifier()), ITEM_LIST,
- item.getIdentifier());
+ cache.removeFromList(makeChildListFqn(childNodesList, item.getParentIdentifier()), ITEM_LIST, item
+ .getIdentifier());
// remove from CHILD_NODES as parent
cache.removeNode(makeChildListFqn(childNodes, item.getIdentifier()));
@@ -938,8 +943,8 @@
.getQPath().getEntries().length - 1]));
// remove from CHILD_PROPS_LIST
- cache.removeFromList(makeChildListFqn(childPropsList, item.getParentIdentifier()), ITEM_LIST,
- item.getIdentifier());
+ cache.removeFromList(makeChildListFqn(childPropsList, item.getParentIdentifier()), ITEM_LIST, item
+ .getIdentifier());
}
// remove from ITEMS
cache.removeNode(makeItemFqn(item.getIdentifier()));
@@ -1077,9 +1082,9 @@
NodeData prevNode = (NodeData)data;
TransientNodeData newNode =
- new TransientNodeData(newPath, prevNode.getIdentifier(), prevNode.getPersistedVersion(),
- prevNode.getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(),
- prevNode.getParentIdentifier(), inheritACL ? acl : prevNode.getACL()); // TODO check ACL
+ new TransientNodeData(newPath, prevNode.getIdentifier(), prevNode.getPersistedVersion(), prevNode
+ .getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
+ .getParentIdentifier(), inheritACL ? acl : prevNode.getACL()); // TODO check ACL
// update this node
cache.put(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
}
@@ -1097,8 +1102,8 @@
}
TransientPropertyData newProp =
- new TransientPropertyData(newPath, prevProp.getIdentifier(), prevProp.getPersistedVersion(),
- prevProp.getType(), prevProp.getParentIdentifier(), prevProp.isMultiValued(), prevProp.getValues());
+ new TransientPropertyData(newPath, prevProp.getIdentifier(), prevProp.getPersistedVersion(), prevProp
+ .getType(), prevProp.getParentIdentifier(), prevProp.isMultiValued(), prevProp.getValues());
cache.put(makeItemFqn(newProp.getIdentifier()), ITEM_DATA, newProp);
}
}
@@ -1132,8 +1137,8 @@
QPath
.makeChildPath(rootPath, prevProp.getQPath().getEntries()[prevProp.getQPath().getEntries().length - 1]);
TransientPropertyData newProp =
- new TransientPropertyData(newPath, prevProp.getIdentifier(), prevProp.getPersistedVersion(),
- prevProp.getType(), prevProp.getParentIdentifier(), prevProp.isMultiValued(), prevProp.getValues());
+ new TransientPropertyData(newPath, prevProp.getIdentifier(), prevProp.getPersistedVersion(), prevProp
+ .getType(), prevProp.getParentIdentifier(), prevProp.isMultiValued(), prevProp.getValues());
cache.put(makeItemFqn(newProp.getIdentifier()), ITEM_DATA, newProp);
}
@@ -1146,9 +1151,9 @@
QPath
.makeChildPath(rootPath, prevNode.getQPath().getEntries()[prevNode.getQPath().getEntries().length - 1]);
TransientNodeData newNode =
- new TransientNodeData(newPath, prevNode.getIdentifier(), prevNode.getPersistedVersion(),
- prevNode.getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(),
- prevNode.getParentIdentifier(), inheritACL ? acl : prevNode.getACL()); // TODO check ACL
+ new TransientNodeData(newPath, prevNode.getIdentifier(), prevNode.getPersistedVersion(), prevNode
+ .getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
+ .getParentIdentifier(), inheritACL ? acl : prevNode.getACL()); // TODO check ACL
// update this node
cache.put(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
// update childs recursive
@@ -1178,8 +1183,8 @@
// recreate with new path for child Nodes only
TransientNodeData newNode =
new TransientNodeData(prevNode.getQPath(), prevNode.getIdentifier(), prevNode.getPersistedVersion(),
- prevNode.getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(),
- prevNode.getParentIdentifier(), acl);
+ prevNode.getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
+ .getParentIdentifier(), acl);
// update this node
cache.put(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
// update childs recursive
13 years, 6 months
exo-jcr SVN: r3401 - in jcr/branches/1.12.x/exo.jcr.component.ext: src/main/java/org/exoplatform/services/jcr/ext/metadata and 1 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-11-05 06:46:02 -0400 (Fri, 05 Nov 2010)
New Revision: 3401
Modified:
jcr/branches/1.12.x/exo.jcr.component.ext/pom.xml
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java
jcr/branches/1.12.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/metadata/MetaDataActionTest.java
Log:
JCR-1487 : Problem with 'Empty metadata field not updated when re-uploading documents' was fixed
Modified: jcr/branches/1.12.x/exo.jcr.component.ext/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.ext/pom.xml 2010-11-05 07:57:05 UTC (rev 3400)
+++ jcr/branches/1.12.x/exo.jcr.component.ext/pom.xml 2010-11-05 10:46:02 UTC (rev 3401)
@@ -141,6 +141,7 @@
<testResource>
<directory>src/test/resources</directory>
<includes>
+ <include>**/*.pdf</include>
<include>**/*.xml</include>
<include>**/*.xls</include>
<include>**/*.groovy</include>
Modified: jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java 2010-11-05 07:57:05 UTC (rev 3400)
+++ jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java 2010-11-05 10:46:02 UTC (rev 3401)
@@ -18,6 +18,18 @@
*/
package org.exoplatform.services.jcr.ext.metadata;
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Map.Entry;
+
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.ValueFormatException;
+
import org.apache.commons.chain.Context;
import org.exoplatform.commons.utils.QName;
import org.exoplatform.container.ExoContainer;
@@ -35,18 +47,6 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
-import java.io.InputStream;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Map.Entry;
-
-import javax.jcr.PathNotFoundException;
-import javax.jcr.Value;
-import javax.jcr.ValueFactory;
-import javax.jcr.ValueFormatException;
-
/**
* Created by The eXo Platform SAS .
*
@@ -104,11 +104,14 @@
return false;
}
- if (!parent.isNodeType("dc:elementSet"))
+ // remove old "dc:elementSet" properties
+ if (parent.isNodeType("dc:elementSet"))
{
- parent.addMixin("dc:elementSet");
+ parent.removeMixin("dc:elementSet");
}
+ parent.addMixin("dc:elementSet");
+
DocumentReaderService readerService =
(DocumentReaderService)((ExoContainer)ctx.get("exocontainer"))
.getComponentInstanceOfType(DocumentReaderService.class);
Modified: jcr/branches/1.12.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/metadata/MetaDataActionTest.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/metadata/MetaDataActionTest.java 2010-11-05 07:57:05 UTC (rev 3400)
+++ jcr/branches/1.12.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/metadata/MetaDataActionTest.java 2010-11-05 10:46:02 UTC (rev 3401)
@@ -18,13 +18,13 @@
*/
package org.exoplatform.services.jcr.ext.metadata;
-import org.exoplatform.services.jcr.ext.BaseStandaloneTest;
-
import java.io.InputStream;
import java.util.Calendar;
import javax.jcr.Node;
+import org.exoplatform.services.jcr.ext.BaseStandaloneTest;
+
public class MetaDataActionTest extends BaseStandaloneTest
{
@@ -122,4 +122,43 @@
assertFalse(contentNode.hasProperty("dc:date"));
assertFalse(contentNode.hasProperty("dc:creator"));
}
+
+ public void testUpdatePDF() throws Exception
+ {
+ InputStream is = MetaDataActionTest.class.getResourceAsStream("/test_1.pdf");
+
+ Node rootNode = session.getRootNode().addNode("MetaDataActionTest");
+ Node contentNode = rootNode.addNode("testAddContent", "nt:resource");
+ contentNode.setProperty("jcr:data", is);
+ contentNode.setProperty("jcr:encoding", "UTF-8");
+ contentNode.setProperty("jcr:mimeType", "application/pdf");
+ contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
+ session.save();
+
+ Node testNode = repository.getSystemSession().getRootNode().getNode("MetaDataActionTest/testAddContent");
+ assertTrue(testNode.hasProperty("dc:title"));
+ assertTrue(testNode.hasProperty("dc:creator"));
+ assertEquals("Title_1", testNode.getProperty("dc:title").getValues()[0].getString());
+ assertEquals("Author_1", testNode.getProperty("dc:creator").getValues()[0].getString());
+
+ // update #1
+ is = MetaDataActionTest.class.getResourceAsStream("/test_2.pdf");
+ contentNode.setProperty("jcr:data", is);
+ session.save();
+
+ testNode = repository.getSystemSession().getRootNode().getNode("MetaDataActionTest/testAddContent");
+ assertTrue(testNode.hasProperty("dc:title"));
+ assertTrue(testNode.hasProperty("dc:creator"));
+ assertEquals("Title_2", testNode.getProperty("dc:title").getValues()[0].getString());
+ assertEquals("Author_2", testNode.getProperty("dc:creator").getValues()[0].getString());
+
+ // update #2
+ is = MetaDataActionTest.class.getResourceAsStream("/test_3.pdf");
+ contentNode.setProperty("jcr:data", is);
+ session.save();
+
+ testNode = repository.getSystemSession().getRootNode().getNode("MetaDataActionTest/testAddContent");
+ assertFalse(testNode.hasProperty("dc:title"));
+ assertFalse(testNode.hasProperty("dc:creator"));
+ }
}
13 years, 6 months
exo-jcr SVN: r3400 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-11-05 03:57:05 -0400 (Fri, 05 Nov 2010)
New Revision: 3400
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java
Log:
EXOJCR-1036 : The problem 'Empty metadata field not updated when re-uploading documents' was fixed
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java 2010-11-04 16:05:01 UTC (rev 3399)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java 2010-11-05 07:57:05 UTC (rev 3400)
@@ -110,10 +110,7 @@
parent.removeMixin("dc:elementSet");
}
- if (!parent.isNodeType("dc:elementSet"))
- {
- parent.addMixin("dc:elementSet");
- }
+ parent.addMixin("dc:elementSet");
DocumentReaderService readerService =
(DocumentReaderService)((ExoContainer)ctx.get("exocontainer"))
13 years, 6 months
exo-jcr SVN: r3399 - in jcr/trunk/exo.jcr.component.ext: src/main/java/org/exoplatform/services/jcr/ext/metadata and 2 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-11-04 12:05:01 -0400 (Thu, 04 Nov 2010)
New Revision: 3399
Added:
jcr/trunk/exo.jcr.component.ext/src/test/resources/test_1.pdf
jcr/trunk/exo.jcr.component.ext/src/test/resources/test_2.pdf
jcr/trunk/exo.jcr.component.ext/src/test/resources/test_3.pdf
Modified:
jcr/trunk/exo.jcr.component.ext/pom.xml
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/metadata/MetaDataActionTest.java
Log:
EXOJCR-1036 : The problem 'Empty metadata field not updated when re-uploading documents' was fixed
Modified: jcr/trunk/exo.jcr.component.ext/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/pom.xml 2010-11-04 16:01:43 UTC (rev 3398)
+++ jcr/trunk/exo.jcr.component.ext/pom.xml 2010-11-04 16:05:01 UTC (rev 3399)
@@ -141,6 +141,7 @@
<testResource>
<directory>src/test/resources</directory>
<includes>
+ <include>**/*.pdf</include>
<include>**/*.xml</include>
<include>**/*.xls</include>
<include>**/*.groovy</include>
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java 2010-11-04 16:01:43 UTC (rev 3398)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java 2010-11-04 16:05:01 UTC (rev 3399)
@@ -18,6 +18,18 @@
*/
package org.exoplatform.services.jcr.ext.metadata;
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Map.Entry;
+
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.ValueFormatException;
+
import org.apache.commons.chain.Context;
import org.exoplatform.commons.utils.QName;
import org.exoplatform.container.ExoContainer;
@@ -35,18 +47,6 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
-import java.io.InputStream;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Map.Entry;
-
-import javax.jcr.PathNotFoundException;
-import javax.jcr.Value;
-import javax.jcr.ValueFactory;
-import javax.jcr.ValueFormatException;
-
/**
* Created by The eXo Platform SAS .
*
@@ -104,6 +104,12 @@
return false;
}
+ // remove old "dc:elementSet" properties
+ if (parent.isNodeType("dc:elementSet"))
+ {
+ parent.removeMixin("dc:elementSet");
+ }
+
if (!parent.isNodeType("dc:elementSet"))
{
parent.addMixin("dc:elementSet");
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/metadata/MetaDataActionTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/metadata/MetaDataActionTest.java 2010-11-04 16:01:43 UTC (rev 3398)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/metadata/MetaDataActionTest.java 2010-11-04 16:05:01 UTC (rev 3399)
@@ -122,4 +122,43 @@
assertFalse(contentNode.hasProperty("dc:date"));
assertFalse(contentNode.hasProperty("dc:creator"));
}
+
+ public void testUpdatePDF() throws Exception
+ {
+ InputStream is = MetaDataActionTest.class.getResourceAsStream("/test_1.pdf");
+
+ Node rootNode = session.getRootNode().addNode("MetaDataActionTest");
+ Node contentNode = rootNode.addNode("testAddContent", "nt:resource");
+ contentNode.setProperty("jcr:data", is);
+ contentNode.setProperty("jcr:encoding", "UTF-8");
+ contentNode.setProperty("jcr:mimeType", "application/pdf");
+ contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
+ session.save();
+
+ Node testNode = repository.getSystemSession().getRootNode().getNode("MetaDataActionTest/testAddContent");
+ assertTrue(testNode.hasProperty("dc:title"));
+ assertTrue(testNode.hasProperty("dc:creator"));
+ assertEquals("Title_1", testNode.getProperty("dc:title").getValues()[0].getString());
+ assertEquals("Author_1", testNode.getProperty("dc:creator").getValues()[0].getString());
+
+ // update #1
+ is = MetaDataActionTest.class.getResourceAsStream("/test_2.pdf");
+ contentNode.setProperty("jcr:data", is);
+ session.save();
+
+ testNode = repository.getSystemSession().getRootNode().getNode("MetaDataActionTest/testAddContent");
+ assertTrue(testNode.hasProperty("dc:title"));
+ assertTrue(testNode.hasProperty("dc:creator"));
+ assertEquals("Title_2", testNode.getProperty("dc:title").getValues()[0].getString());
+ assertEquals("Author_2", testNode.getProperty("dc:creator").getValues()[0].getString());
+
+ // update #2
+ is = MetaDataActionTest.class.getResourceAsStream("/test_3.pdf");
+ contentNode.setProperty("jcr:data", is);
+ session.save();
+
+ testNode = repository.getSystemSession().getRootNode().getNode("MetaDataActionTest/testAddContent");
+ assertFalse(testNode.hasProperty("dc:title"));
+ assertFalse(testNode.hasProperty("dc:creator"));
+ }
}
Added: jcr/trunk/exo.jcr.component.ext/src/test/resources/test_1.pdf
===================================================================
(Binary files differ)
Property changes on: jcr/trunk/exo.jcr.component.ext/src/test/resources/test_1.pdf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jcr/trunk/exo.jcr.component.ext/src/test/resources/test_2.pdf
===================================================================
(Binary files differ)
Property changes on: jcr/trunk/exo.jcr.component.ext/src/test/resources/test_2.pdf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jcr/trunk/exo.jcr.component.ext/src/test/resources/test_3.pdf
===================================================================
(Binary files differ)
Property changes on: jcr/trunk/exo.jcr.component.ext/src/test/resources/test_3.pdf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
13 years, 6 months
exo-jcr SVN: r3398 - in jcr/trunk/exo.jcr.component.ext: src/main/java/org/exoplatform/services/jcr/ext/metadata and 2 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-11-04 12:01:43 -0400 (Thu, 04 Nov 2010)
New Revision: 3398
Removed:
jcr/trunk/exo.jcr.component.ext/src/test/resources/test_1.pdf
jcr/trunk/exo.jcr.component.ext/src/test/resources/test_2.pdf
jcr/trunk/exo.jcr.component.ext/src/test/resources/test_3.pdf
Modified:
jcr/trunk/exo.jcr.component.ext/pom.xml
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/metadata/MetaDataActionTest.java
Log:
EXOJCR-1036 : Revert changes to rev. 3396
Modified: jcr/trunk/exo.jcr.component.ext/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/pom.xml 2010-11-04 15:53:05 UTC (rev 3397)
+++ jcr/trunk/exo.jcr.component.ext/pom.xml 2010-11-04 16:01:43 UTC (rev 3398)
@@ -141,7 +141,6 @@
<testResource>
<directory>src/test/resources</directory>
<includes>
- <include>**/*.pdf</include>
<include>**/*.xml</include>
<include>**/*.xls</include>
<include>**/*.groovy</include>
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java 2010-11-04 15:53:05 UTC (rev 3397)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java 2010-11-04 16:01:43 UTC (rev 3398)
@@ -18,18 +18,6 @@
*/
package org.exoplatform.services.jcr.ext.metadata;
-import java.io.InputStream;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Map.Entry;
-
-import javax.jcr.PathNotFoundException;
-import javax.jcr.Value;
-import javax.jcr.ValueFactory;
-import javax.jcr.ValueFormatException;
-
import org.apache.commons.chain.Context;
import org.exoplatform.commons.utils.QName;
import org.exoplatform.container.ExoContainer;
@@ -47,6 +35,18 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Map.Entry;
+
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.ValueFormatException;
+
/**
* Created by The eXo Platform SAS .
*
@@ -104,12 +104,6 @@
return false;
}
- // remove old "dc:elementSet" properties
- if (parent.isNodeType("dc:elementSet"))
- {
- parent.removeMixin("dc:elementSet");
- }
-
if (!parent.isNodeType("dc:elementSet"))
{
parent.addMixin("dc:elementSet");
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/metadata/MetaDataActionTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/metadata/MetaDataActionTest.java 2010-11-04 15:53:05 UTC (rev 3397)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/metadata/MetaDataActionTest.java 2010-11-04 16:01:43 UTC (rev 3398)
@@ -122,43 +122,4 @@
assertFalse(contentNode.hasProperty("dc:date"));
assertFalse(contentNode.hasProperty("dc:creator"));
}
-
- public void testUpdatePDF() throws Exception
- {
- InputStream is = MetaDataActionTest.class.getResourceAsStream("/test_1.pdf");
-
- Node rootNode = session.getRootNode().addNode("MetaDataActionTest");
- Node contentNode = rootNode.addNode("testAddContent", "nt:resource");
- contentNode.setProperty("jcr:data", is);
- contentNode.setProperty("jcr:encoding", "UTF-8");
- contentNode.setProperty("jcr:mimeType", "application/pdf");
- contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
- session.save();
-
- Node testNode = repository.getSystemSession().getRootNode().getNode("MetaDataActionTest/testAddContent");
- assertTrue(testNode.hasProperty("dc:title"));
- assertTrue(testNode.hasProperty("dc:creator"));
- assertEquals("Title_1", testNode.getProperty("dc:title").getValues()[0].getString());
- assertEquals("Author_1", testNode.getProperty("dc:creator").getValues()[0].getString());
-
- // update #1
- is = MetaDataActionTest.class.getResourceAsStream("/test_2.pdf");
- contentNode.setProperty("jcr:data", is);
- session.save();
-
- testNode = repository.getSystemSession().getRootNode().getNode("MetaDataActionTest/testAddContent");
- assertTrue(testNode.hasProperty("dc:title"));
- assertTrue(testNode.hasProperty("dc:creator"));
- assertEquals("Title_2", testNode.getProperty("dc:title").getValues()[0].getString());
- assertEquals("Author_2", testNode.getProperty("dc:creator").getValues()[0].getString());
-
- // update #2
- is = MetaDataActionTest.class.getResourceAsStream("/test_3.pdf");
- contentNode.setProperty("jcr:data", is);
- session.save();
-
- testNode = repository.getSystemSession().getRootNode().getNode("MetaDataActionTest/testAddContent");
- assertFalse(testNode.hasProperty("dc:title"));
- assertFalse(testNode.hasProperty("dc:creator"));
- }
}
Deleted: jcr/trunk/exo.jcr.component.ext/src/test/resources/test_1.pdf
===================================================================
(Binary files differ)
Deleted: jcr/trunk/exo.jcr.component.ext/src/test/resources/test_2.pdf
===================================================================
(Binary files differ)
Deleted: jcr/trunk/exo.jcr.component.ext/src/test/resources/test_3.pdf
===================================================================
(Binary files differ)
13 years, 6 months
exo-jcr SVN: r3397 - in jcr/trunk/exo.jcr.component.ext: src/main/java/org/exoplatform/services/jcr/ext/metadata and 2 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-11-04 11:53:05 -0400 (Thu, 04 Nov 2010)
New Revision: 3397
Added:
jcr/trunk/exo.jcr.component.ext/src/test/resources/test_1.pdf
jcr/trunk/exo.jcr.component.ext/src/test/resources/test_2.pdf
jcr/trunk/exo.jcr.component.ext/src/test/resources/test_3.pdf
Modified:
jcr/trunk/exo.jcr.component.ext/pom.xml
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/metadata/MetaDataActionTest.java
Log:
JCR-1487 : The problem 'Empty metadata field not updated when re-uploading documents' was fixed
Modified: jcr/trunk/exo.jcr.component.ext/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/pom.xml 2010-11-04 14:31:06 UTC (rev 3396)
+++ jcr/trunk/exo.jcr.component.ext/pom.xml 2010-11-04 15:53:05 UTC (rev 3397)
@@ -141,6 +141,7 @@
<testResource>
<directory>src/test/resources</directory>
<includes>
+ <include>**/*.pdf</include>
<include>**/*.xml</include>
<include>**/*.xls</include>
<include>**/*.groovy</include>
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java 2010-11-04 14:31:06 UTC (rev 3396)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/metadata/AddMetadataAction.java 2010-11-04 15:53:05 UTC (rev 3397)
@@ -18,6 +18,18 @@
*/
package org.exoplatform.services.jcr.ext.metadata;
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Map.Entry;
+
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.ValueFormatException;
+
import org.apache.commons.chain.Context;
import org.exoplatform.commons.utils.QName;
import org.exoplatform.container.ExoContainer;
@@ -35,18 +47,6 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
-import java.io.InputStream;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Map.Entry;
-
-import javax.jcr.PathNotFoundException;
-import javax.jcr.Value;
-import javax.jcr.ValueFactory;
-import javax.jcr.ValueFormatException;
-
/**
* Created by The eXo Platform SAS .
*
@@ -104,6 +104,12 @@
return false;
}
+ // remove old "dc:elementSet" properties
+ if (parent.isNodeType("dc:elementSet"))
+ {
+ parent.removeMixin("dc:elementSet");
+ }
+
if (!parent.isNodeType("dc:elementSet"))
{
parent.addMixin("dc:elementSet");
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/metadata/MetaDataActionTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/metadata/MetaDataActionTest.java 2010-11-04 14:31:06 UTC (rev 3396)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/metadata/MetaDataActionTest.java 2010-11-04 15:53:05 UTC (rev 3397)
@@ -122,4 +122,43 @@
assertFalse(contentNode.hasProperty("dc:date"));
assertFalse(contentNode.hasProperty("dc:creator"));
}
+
+ public void testUpdatePDF() throws Exception
+ {
+ InputStream is = MetaDataActionTest.class.getResourceAsStream("/test_1.pdf");
+
+ Node rootNode = session.getRootNode().addNode("MetaDataActionTest");
+ Node contentNode = rootNode.addNode("testAddContent", "nt:resource");
+ contentNode.setProperty("jcr:data", is);
+ contentNode.setProperty("jcr:encoding", "UTF-8");
+ contentNode.setProperty("jcr:mimeType", "application/pdf");
+ contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
+ session.save();
+
+ Node testNode = repository.getSystemSession().getRootNode().getNode("MetaDataActionTest/testAddContent");
+ assertTrue(testNode.hasProperty("dc:title"));
+ assertTrue(testNode.hasProperty("dc:creator"));
+ assertEquals("Title_1", testNode.getProperty("dc:title").getValues()[0].getString());
+ assertEquals("Author_1", testNode.getProperty("dc:creator").getValues()[0].getString());
+
+ // update #1
+ is = MetaDataActionTest.class.getResourceAsStream("/test_2.pdf");
+ contentNode.setProperty("jcr:data", is);
+ session.save();
+
+ testNode = repository.getSystemSession().getRootNode().getNode("MetaDataActionTest/testAddContent");
+ assertTrue(testNode.hasProperty("dc:title"));
+ assertTrue(testNode.hasProperty("dc:creator"));
+ assertEquals("Title_2", testNode.getProperty("dc:title").getValues()[0].getString());
+ assertEquals("Author_2", testNode.getProperty("dc:creator").getValues()[0].getString());
+
+ // update #2
+ is = MetaDataActionTest.class.getResourceAsStream("/test_3.pdf");
+ contentNode.setProperty("jcr:data", is);
+ session.save();
+
+ testNode = repository.getSystemSession().getRootNode().getNode("MetaDataActionTest/testAddContent");
+ assertFalse(testNode.hasProperty("dc:title"));
+ assertFalse(testNode.hasProperty("dc:creator"));
+ }
}
Added: jcr/trunk/exo.jcr.component.ext/src/test/resources/test_1.pdf
===================================================================
(Binary files differ)
Property changes on: jcr/trunk/exo.jcr.component.ext/src/test/resources/test_1.pdf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jcr/trunk/exo.jcr.component.ext/src/test/resources/test_2.pdf
===================================================================
(Binary files differ)
Property changes on: jcr/trunk/exo.jcr.component.ext/src/test/resources/test_2.pdf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jcr/trunk/exo.jcr.component.ext/src/test/resources/test_3.pdf
===================================================================
(Binary files differ)
Property changes on: jcr/trunk/exo.jcr.component.ext/src/test/resources/test_3.pdf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
13 years, 6 months