Author: nzamosenchuk
Date: 2011-11-30 05:09:02 -0500 (Wed, 30 Nov 2011)
New Revision: 5244
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientItemData.java
Log:
EXOJCR-1651 : Adding a check to avoid cycles in future.
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java 2011-11-29
11:55:14 UTC (rev 5243)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java 2011-11-30
10:09:02 UTC (rev 5244)
@@ -66,6 +66,10 @@
public PersistedItemData(String id, QPath qpath, String parentId, int version)
{
+ if (id.equals(parentId))
+ {
+ throw new IllegalArgumentException("Item can't have itself as
parent.");
+ }
this.id = id;
this.qpath = qpath;
this.parentId = parentId;
@@ -110,10 +114,14 @@
public boolean equals(Object obj)
{
if (obj == this)
+ {
return true;
+ }
if (obj == null)
+ {
return false;
+ }
if (obj instanceof ItemData)
{
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientItemData.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientItemData.java 2011-11-29
11:55:14 UTC (rev 5243)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientItemData.java 2011-11-30
10:09:02 UTC (rev 5244)
@@ -67,6 +67,10 @@
*/
TransientItemData(QPath path, String identifier, int version, String
parentIdentifier)
{
+ if (identifier.equals(parentIdentifier))
+ {
+ throw new IllegalArgumentException("Item can't have itself as
parent.");
+ }
this.parentIdentifier = parentIdentifier != null ? parentIdentifier : null;
this.identifier = identifier;
this.qpath = path;
@@ -82,10 +86,14 @@
public boolean equals(Object obj)
{
if (obj == this)
+ {
return true;
+ }
if (obj == null)
+ {
return false;
+ }
if (obj instanceof ItemData)
{
@@ -208,7 +216,9 @@
out.write(parentIdentifier.getBytes());
}
else
+ {
out.writeInt(NULL_VALUE);
+ }
out.writeInt(persistedVersion);
}
Show replies by date