Author: nzamosenchuk
Date: 2011-09-28 04:31:57 -0400 (Wed, 28 Sep 2011)
New Revision: 4991
Added:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/DummySession.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLog.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/JCRRestore.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ActionLauncher.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataMergeVisitor.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataRestoreVisitor.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/observation/TestSessionsObservation.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestItemDataChangesLog.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLogTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestJCRVSReadWrite.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/version/BaseVersionImplTest.java
Log:
EXOJCR-1562 : add Session instance to PlainChangesLog.
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLog.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLog.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLog.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -22,6 +22,8 @@
import java.util.List;
+import javax.jcr.Session;
+
/**
* Created by The eXo Platform SAS.<br/> Plain changes log implementation (i.e. no
nested logs
* inside)
@@ -38,7 +40,7 @@
* @return sessionId of a session produced this changes log
*/
String getSessionId();
-
+
/**
* Return pair Id of system and non-system logs.
*
@@ -67,4 +69,10 @@
* @param states List of ItemState
*/
PlainChangesLog addAll(List<ItemState> states);
+
+ /**
+ * Returns session instance is present
+ * @return session instance
+ */
+ Session getSession();
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.services.jcr.dataflow;
+import org.exoplatform.services.jcr.core.ExtendedSession;
import org.exoplatform.services.jcr.impl.Constants;
import java.io.Externalizable;
@@ -27,6 +28,8 @@
import java.util.ArrayList;
import java.util.List;
+import javax.jcr.Session;
+
/**
* Created by The eXo Platform SAS.
*
@@ -37,7 +40,7 @@
public class PlainChangesLogImpl implements Externalizable, PlainChangesLog
{
private static final int NULL_VALUE = -1;
-
+
private static final int NOT_NULL_VALUE = 1;
private static final long serialVersionUID = 5624550860372364084L;
@@ -48,15 +51,34 @@
protected int eventType;
+ protected ExtendedSession session;
+
/**
* Identifier of system and non-system logs pair. Null if no pair found.
*/
- protected String pairId = null;
+ protected String pairId;
/**
* Full qualified constructor.
*
* @param items List of ItemState
+ * @param session Session
+ * @param eventType int
+ * @param pairId String
+ */
+ public PlainChangesLogImpl(List<ItemState> items, Session session, int
eventType, String pairId)
+ {
+ this.items = items;
+ this.session = (ExtendedSession)session;
+ this.sessionId = this.session.getId();
+ this.eventType = eventType;
+ this.pairId = pairId;
+ }
+
+ /**
+ * Full qualified constructor. Used for compatibility with asynchronous replication.
+ *
+ * @param items List of ItemState
* @param sessionId String
* @param eventType int
* @param pairId String
@@ -73,35 +95,57 @@
* Constructor.
*
* @param items List of ItemState
+ * @param session Session
+ * @param eventType int
+ */
+ public PlainChangesLogImpl(List<ItemState> items, Session session, int
eventType)
+ {
+ this(items, session, eventType, null);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param items List of ItemState
* @param sessionId String
* @param eventType int
*/
public PlainChangesLogImpl(List<ItemState> items, String sessionId, int
eventType)
{
- this.items = items;
- this.sessionId = sessionId;
- this.eventType = eventType;
+ this(items, sessionId, eventType, null);
}
+ //
+
/**
* Constructor with undefined event type.
*
* @param items List of ItemState
- * @param sessionId String
+ * @param session Session
*/
- public PlainChangesLogImpl(List<ItemState> items, String sessionId)
+ public PlainChangesLogImpl(List<ItemState> items, Session session)
{
- this(items, sessionId, -1);
+ this(items, session, -1);
}
/**
* An empty log.
*
+ * @param session Session
+ */
+ public PlainChangesLogImpl(Session session)
+ {
+ this(new ArrayList<ItemState>(), session);
+ }
+
+ /**
+ * An empty log.
+ *
* @param sessionId String
*/
public PlainChangesLogImpl(String sessionId)
{
- this(new ArrayList<ItemState>(), sessionId);
+ this(new ArrayList<ItemState>(), sessionId, -1);
}
/**
@@ -109,7 +153,7 @@
*/
public PlainChangesLogImpl()
{
- this(new ArrayList<ItemState>(), null);
+ this(new ArrayList<ItemState>(), (String)null, -1);
}
/*
@@ -152,6 +196,14 @@
return sessionId;
}
+ /**
+ * {@inheritDoc}
+ */
+ public Session getSession()
+ {
+ return session;
+ }
+
/*
* (non-Javadoc)
*
@@ -200,11 +252,13 @@
{
String str = "ChangesLog: \n";
for (int i = 0; i < items.size(); i++)
+ {
str +=
" " + ItemState.nameFromValue(items.get(i).getState()) +
"\t" + items.get(i).getData().getIdentifier()
+ "\t" + "isPersisted=" + items.get(i).isPersisted() +
"\t" + "isEventFire="
+ items.get(i).isEventFire() + "\t" +
"isInternallyCreated=" + items.get(i).isInternallyCreated() + "\t"
+ items.get(i).getData().getQPath().getAsString() + "\n";
+ }
return str;
}
@@ -227,7 +281,7 @@
out.writeObject(items.get(i));
}
- if (pairId != null)
+ if (pairId != null)
{
out.writeInt(NOT_NULL_VALUE);
buff = pairId.getBytes(Constants.DEFAULT_ENCODING);
@@ -253,7 +307,7 @@
{
add((ItemState)in.readObject());
}
-
+
if (in.readInt() == NOT_NULL_VALUE)
{
buf = new byte[in.readInt()];
@@ -261,5 +315,7 @@
pairId = new String(buf, Constants.DEFAULT_ENCODING);
}
}
+
// ------------------ [ END ] ------------------
+
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/JCRRestore.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/JCRRestore.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/JCRRestore.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -171,7 +171,9 @@
while (cli.hasNextLog())
{
if (cli.nextLog().getEventType() == ExtendedEvent.LOCK)
+ {
cli.removeLog();
+ }
}
saveChangesLog(changesLog);
@@ -194,22 +196,30 @@
TransactionChangesLog normalizeChangesLog =
getNormalizedChangesLog(e.getIdentifier(), e.getState(), changesLog);
if (normalizeChangesLog != null)
+ {
saveChangesLog(normalizeChangesLog);
+ }
else
+ {
throw new RepositoryException(
"Collisions found during save of restore changes log, but caused item
is not found by ID "
+ e.getIdentifier() + ". " + e, e);
+ }
}
catch (JCRItemExistsException e)
{
TransactionChangesLog normalizeChangesLog =
getNormalizedChangesLog(e.getIdentifier(), e.getState(), changesLog);
if (normalizeChangesLog != null)
+ {
saveChangesLog(normalizeChangesLog);
+ }
else
+ {
throw new RepositoryException(
"Collisions found during save of restore changes log, but caused item
is not found by ID "
+ e.getIdentifier() + ". " + e, e);
+ }
}
}
@@ -239,7 +249,9 @@
// Node... by ID and desc path
if (!item.getIdentifier().equals(collisionID)
&&
!item.getQPath().isDescendantOf(citem.getData().getQPath()))
+ {
normalized.add(change);
+ }
}
else if (!item.getIdentifier().equals(collisionID))
{
@@ -248,11 +260,21 @@
}
}
else
+ {
// another state
normalized.add(change);
+ }
}
- PlainChangesLog plog = new PlainChangesLogImpl(normalized,
next.getSessionId(), next.getEventType());
+ PlainChangesLog plog;
+ if (next.getSession() != null)
+ {
+ plog = new PlainChangesLogImpl(normalized, next.getSession(),
next.getEventType());
+ }
+ else
+ {
+ plog = new PlainChangesLogImpl(normalized, next.getSessionId(),
next.getEventType());
+ }
result.addLog(plog);
}
@@ -393,7 +415,9 @@
}
for (int i = 0; i < listFile.size(); i++)
+ {
fileCleaner.addFile(listFile.get(i));
+ }
}
}
@@ -427,9 +451,13 @@
{
boolean b = true;
if (fs.getItemSateId() != this.getItemSateId())
+ {
b = false;
+ }
if (fs.getValueDataId() != this.getValueDataId())
+ {
b = false;
+ }
return b;
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -413,7 +413,7 @@
checkValid();
- PlainChangesLog changesLog = new PlainChangesLogImpl(session.getId());
+ PlainChangesLog changesLog = new PlainChangesLogImpl(session);
removeMergeFailed(version, changesLog);
@@ -497,7 +497,7 @@
// the new version identifier
String verIdentifier = IdGenerator.generate();
- SessionChangesLog changesLog = new SessionChangesLog(session.getId());
+ SessionChangesLog changesLog = new SessionChangesLog(session);
VersionHistoryImpl vh = versionHistory(false);
vh.addVersion(this.nodeData(), verIdentifier, changesLog);
@@ -550,7 +550,7 @@
return;
}
- SessionChangesLog changesLog = new SessionChangesLog(session.getId());
+ SessionChangesLog changesLog = new SessionChangesLog(session);
changesLog.add(ItemState.createUpdatedState(updatePropertyData(Constants.JCR_ISCHECKEDOUT,
new TransientValueData(true))));
@@ -711,7 +711,7 @@
+ session.getUserID() + " item owner " + getACL().getOwner());
}
- PlainChangesLog changesLog = new PlainChangesLogImpl(session.getId());
+ PlainChangesLog changesLog = new PlainChangesLogImpl(session);
VersionImpl base = (VersionImpl)getBaseVersion();
base.addPredecessor(version.getUUID(), changesLog);
@@ -1709,8 +1709,7 @@
Lock newLock = session.getLockManager().addLock(this, isDeep, isSessionScoped,
-1);
- PlainChangesLog changesLog =
- new PlainChangesLogImpl(new ArrayList<ItemState>(), session.getId(),
ExtendedEvent.LOCK);
+ PlainChangesLog changesLog = new PlainChangesLogImpl(new
ArrayList<ItemState>(), session, ExtendedEvent.LOCK);
PropertyData propData =
TransientPropertyData.createPropertyData(nodeData(), Constants.JCR_LOCKOWNER,
PropertyType.STRING, false,
@@ -1758,8 +1757,7 @@
Lock newLock = session.getLockManager().addLock(this, isDeep, false, timeOut);
- PlainChangesLog changesLog =
- new PlainChangesLogImpl(new ArrayList<ItemState>(), session.getId(),
ExtendedEvent.LOCK);
+ PlainChangesLog changesLog = new PlainChangesLogImpl(new
ArrayList<ItemState>(), session, ExtendedEvent.LOCK);
PropertyData propData =
TransientPropertyData.createPropertyData(nodeData(), Constants.JCR_LOCKOWNER,
PropertyType.STRING, false,
@@ -2520,7 +2518,7 @@
throw new LockException("Node " + getPath() + " is locked
");
}
- SessionChangesLog changes = new SessionChangesLog(session.getId());
+ SessionChangesLog changes = new SessionChangesLog(session);
String srcPath;
try
@@ -2850,8 +2848,7 @@
protected void doUnlock() throws RepositoryException
{
- PlainChangesLog changesLog =
- new PlainChangesLogImpl(new ArrayList<ItemState>(), session.getId(),
ExtendedEvent.UNLOCK);
+ PlainChangesLog changesLog = new PlainChangesLogImpl(new
ArrayList<ItemState>(), session, ExtendedEvent.UNLOCK);
ItemData lockOwner =
dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_LOCKOWNER, 0),
ItemType.PROPERTY);
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -107,7 +107,7 @@
public SessionDataManager(SessionImpl session, LocalWorkspaceDataManagerStub
dataManager) throws RepositoryException
{
this.session = session;
- this.changesLog = new SessionChangesLog(session.getId());
+ this.changesLog = new SessionChangesLog(session);
this.itemsPool = new ItemReferencePool();
this.itemFactory = new SessionItemFactory();
this.accessManager = session.getAccessManager();
@@ -2034,7 +2034,7 @@
// remove from changes log (Session pending changes)
PlainChangesLog slog = changesLog.pushLog(item.getQPath());
- SessionChangesLog changes = new SessionChangesLog(slog.getAllStates(),
session.getId());
+ SessionChangesLog changes = new SessionChangesLog(slog.getAllStates(), session);
String exceptions = "";
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -127,7 +127,7 @@
{
session.checkLive();
- SessionChangesLog changes = new SessionChangesLog(session.getId());
+ SessionChangesLog changes = new SessionChangesLog(session);
clone(srcWorkspace, srcAbsPath, destAbsPath, removeExisting, changes);
@@ -214,7 +214,7 @@
srcNode.getData().accept(initializer);
- PlainChangesLogImpl changesLog = new
PlainChangesLogImpl(initializer.getItemAddStates(), session.getId());
+ PlainChangesLogImpl changesLog = new
PlainChangesLogImpl(initializer.getItemAddStates(), session);
session.getTransientNodesManager().getTransactManager().save(changesLog);
}
@@ -466,7 +466,7 @@
(NodeData)srcParentNode.getData(), nodeTypeManager,
session.getTransientNodesManager(), true);
srcNode.getData().accept(initializer);
- PlainChangesLog changes = new PlainChangesLogImpl(session.getId());
+ PlainChangesLog changes = new PlainChangesLogImpl(session);
changes.addAll(initializer.getAllStates());
// reload items pool
@@ -590,7 +590,7 @@
List<VersionImpl> notExistedVersions = new ArrayList<VersionImpl>();
TransactionableDataManager dataManager =
session.getTransientNodesManager().getTransactManager();
- SessionChangesLog changesLog = new SessionChangesLog(session.getId());
+ SessionChangesLog changesLog = new SessionChangesLog(session);
for (Version v : versions)
{
String versionableIdentifier = v.getContainingHistory().getVersionableUUID();
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -40,6 +40,7 @@
import org.exoplatform.services.jcr.observation.ExtendedEvent;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import org.exoplatform.services.security.IdentityConstants;
import java.io.File;
import java.io.IOException;
@@ -162,7 +163,9 @@
return;
}
if (!PrivilegedFileHelper.delete(lockFile))
+ {
throw new LockException("Fail to remove lock information");
+ }
}
@@ -186,7 +189,7 @@
for (int i = 0; i < list.length; i++)
{
PlainChangesLog plainChangesLog =
- new PlainChangesLogImpl(new ArrayList<ItemState>(),
SystemIdentity.SYSTEM, ExtendedEvent.UNLOCK);
+ new PlainChangesLogImpl(new ArrayList<ItemState>(),
IdentityConstants.SYSTEM, ExtendedEvent.UNLOCK);
NodeData lockedNodeData = (NodeData)dataManager.getItemData(list[i]);
// No item no problem
@@ -207,9 +210,11 @@
(PropertyData)dataManager.getItemData(lockedNodeData, new
QPathEntry(Constants.JCR_LOCKOWNER, 0),
ItemType.PROPERTY);
if (dataLockOwner != null)
+ {
plainChangesLog.add(ItemState.createDeletedState(new
TransientPropertyData(QPath.makeChildPath(
lockedNodeData.getQPath(), Constants.JCR_LOCKOWNER),
dataLockOwner.getIdentifier(), 0,
dataLockOwner.getType(), dataLockOwner.getParentIdentifier(),
dataLockOwner.isMultiValued())));
+ }
if (plainChangesLog.getSize() > 0)
{
@@ -232,7 +237,9 @@
log.warn("Persistent lock information for node id " + list[i] +
" doesn't exists");
}
if (!PrivilegedFileHelper.delete(lockFile))
+ {
throw new LockException("Fail to remove lock information");
+ }
}
}
catch (RepositoryException e)
@@ -290,8 +297,10 @@
String root = config.getParameterValue(PARAM_ROOT_DIR);
if (root == null)
+ {
throw new RepositoryConfigurationException("Repository service
configuration." + " Source name ("
+ PARAM_ROOT_DIR + ") is expected");
+ }
rootDir = new File(root);
if (PrivilegedFileHelper.exists(rootDir))
{
@@ -303,7 +312,9 @@
else
{
if (!PrivilegedFileHelper.mkdirs(rootDir))
+ {
throw new RepositoryException("Can't create dir" + root);
+ }
}
}
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ActionLauncher.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ActionLauncher.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ActionLauncher.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -92,9 +92,19 @@
PlainChangesLog subLog = logIterator.nextLog();
String sessionId = subLog.getSessionId();
- SessionImpl userSession = sessionRegistry.getSession(sessionId);
+ SessionImpl userSession;
+ if (subLog.getSession() instanceof SessionImpl)
+ {
+ userSession = (SessionImpl)subLog.getSession();
+ }
+ else
+ {
+ userSession = sessionRegistry.getSession(sessionId);
+ }
+
if (userSession != null)
+ {
for (ItemState itemState : subLog.getAllStates())
{
if (itemState.isEventFire())
@@ -123,6 +133,7 @@
}
}
}
+ }
}
if (events.getSize() > 0)
{
@@ -141,15 +152,15 @@
private boolean isSessionMatch(ListenerCriteria criteria, String sessionId)
{
- if (criteria.getNoLocal() && criteria.getSessionId().equals(sessionId))
- return false;
- return true;
+ return !(criteria.getNoLocal() &&
criteria.getSessionId().equals(sessionId));
}
private boolean isPathMatch(ListenerCriteria criteria, ItemData item, SessionImpl
userSession)
{
if (criteria.getAbsPath() == null)
+ {
return true;
+ }
try
{
QPath cLoc =
userSession.getLocationFactory().parseAbsPath(criteria.getAbsPath()).getInternalPath();
@@ -171,15 +182,21 @@
{
if (criteria.getIdentifier() == null)
+ {
return true;
+ }
// assotiated parent is node itself for node and parent for property ????
for (int i = 0; i < criteria.getIdentifier().length; i++)
{
if (item.isNode() &&
criteria.getIdentifier()[i].equals(item.getIdentifier()))
+ {
return true;
+ }
else if (!item.isNode() &&
criteria.getIdentifier()[i].equals(item.getParentIdentifier()))
+ {
return true;
+ }
}
return false;
@@ -189,7 +206,9 @@
PlainChangesLog changesLog) throws RepositoryException
{
if (criteria.getNodeTypeName() == null)
+ {
return true;
+ }
NodeData node =
(NodeData)workspaceDataManager.getItemData(item.getParentIdentifier());
if (node == null)
@@ -231,7 +250,9 @@
testQNames[0] = node.getPrimaryTypeName();
}
if (ntManager.isNodeType(criteriaNT.getName(), testQNames))
+ {
return true;
+ }
}
return false;
}
@@ -242,24 +263,40 @@
if (state.getData().isNode())
{
if (state.isAdded() || state.isRenamed() || state.isUpdated())
+ {
return Event.NODE_ADDED;
+ }
else if (state.isDeleted())
+ {
return Event.NODE_REMOVED;
+ }
else if (state.isUpdated())
+ {
return SKIP_EVENT;
+ }
else if (state.isUnchanged())
+ {
return SKIP_EVENT;
+ }
}
else
{ // property
if (state.isAdded())
+ {
return Event.PROPERTY_ADDED;
+ }
else if (state.isDeleted())
+ {
return Event.PROPERTY_REMOVED;
+ }
else if (state.isUpdated())
+ {
return Event.PROPERTY_CHANGED;
+ }
else if (state.isUnchanged())
+ {
return SKIP_EVENT;
+ }
}
throw new RepositoryException("Unexpected ItemState for Node " +
ItemState.nameFromValue(state.getState()) + " "
+ state.getData().getQPath().getAsString());
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataMergeVisitor.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataMergeVisitor.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataMergeVisitor.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -174,7 +174,7 @@
this.bestEffort = bestEffort;
this.failed = failed;
- this.changes = new SessionChangesLog(mergeSession.getId());
+ this.changes = new SessionChangesLog(mergeSession);
}
@Override
@@ -530,6 +530,7 @@
ItemType.PROPERTY);
if (predecessorsProperty != null)
+ {
for (ValueData pv : predecessorsProperty.getValues())
{
try
@@ -537,7 +538,9 @@
String pidentifier = new String(pv.getAsByteArray());
if (pidentifier.equals(corrVersion.getIdentifier()))
+ {
return true; // got it
+ }
// search in predecessors of the predecessor
NodeData predecessor =
(NodeData)mergeDataManager.getItemData(pidentifier);
@@ -560,6 +563,7 @@
}
}
// else it's a root version
+ }
return false;
}
@@ -576,6 +580,7 @@
ItemType.PROPERTY);
if (successorsProperty != null)
+ {
for (ValueData sv : successorsProperty.getValues())
{
try
@@ -583,7 +588,9 @@
String sidentifier = new String(sv.getAsByteArray());
if (sidentifier.equals(corrVersion.getIdentifier()))
+ {
return true; // got it
+ }
// search in successors of the successor
NodeData successor = (NodeData)mergeDataManager.getItemData(sidentifier);
@@ -606,6 +613,7 @@
}
}
// else it's a end of version graph node
+ }
return false;
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataRestoreVisitor.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataRestoreVisitor.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataRestoreVisitor.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -282,7 +282,7 @@
super(userSession.getTransientNodesManager().getTransactManager());
this.userSession = userSession;
- this.changes = new SessionChangesLog(userSession.getId());
+ this.changes = new SessionChangesLog(userSession);
this.context = context;
this.destName = destName;
this.history = history;
@@ -309,7 +309,9 @@
for (ItemState state : delegatedChanges.getAllStates())
{
if (state.getData().getIdentifier().equals(identifier))
+ {
return state.getData();
+ }
}
}
@@ -323,7 +325,9 @@
for (ItemState state : delegatedChanges.getAllStates())
{
if (state.getData().getQPath().equals(path))
+ {
return state.getData();
+ }
}
}
@@ -338,7 +342,9 @@
for (ItemState state : delegatedChanges.getAllStates())
{
if (state.getData().getQPath().equals(path) ||
state.getData().getQPath().isDescendantOf(path))
+ {
removed.add(state);
+ }
}
for (ItemState state : removed)
@@ -355,7 +361,9 @@
QPath nodePath = QPath.makeChildPath(parentData.getQPath(), name);
if (log.isDebugEnabled())
+ {
log.debug("Restore: " + nodePath.getAsString() + ",
removeExisting=" + removeExisting);
+ }
PropertyData frozenIdentifier =
(PropertyData)dataManager.getItemData(frozen, new
QPathEntry(Constants.JCR_FROZENUUID, 1), ItemType.PROPERTY);
@@ -386,8 +394,10 @@
// name
if (sameIdentifierPath.getIndex() != nodePath.getIndex())
+ {
// but different index, see below... fix it
nodePath = QPath.makeChildPath(parentData.getQPath(), name,
sameIdentifierPath.getIndex());
+ }
// if it's a target node
existing = sameIdentifierNode;
@@ -606,7 +616,9 @@
NodeData cHistory = null;
if ((cHistory = (NodeData)dataManager.getItemData(vhIdentifier)) == null)
+ {
throw new RepositoryException("Version history is not found with uuid
" + vhIdentifier);
+ }
childHistory = new VersionHistoryDataHelper(cHistory, dataManager,
nodeTypeDataManager);
}
@@ -839,6 +851,7 @@
InternalQName qname = property.getQPath().getName();
if (nodeTypeDataManager.isNodeType(Constants.NT_FROZENNODE,
frozenParent.getPrimaryTypeName()))
+ {
if (qname.equals(Constants.JCR_FROZENPRIMARYTYPE))
{
qname = Constants.JCR_PRIMARYTYPE;
@@ -857,6 +870,7 @@
// skip these props, as they are a nt:frozenNode special props
return;
}
+ }
int action =
nodeTypeDataManager
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -347,7 +347,7 @@
+ refs.get(0).getQPath().getAsString());
}
- PlainChangesLog changes = new PlainChangesLogImpl(session.getId());
+ PlainChangesLog changes = new PlainChangesLogImpl(session);
// remove labels first
try
@@ -527,7 +527,7 @@
NodeData versionData = getVersionData(versionName);
- SessionChangesLog changesLog = new SessionChangesLog(session.getId());
+ SessionChangesLog changesLog = new SessionChangesLog(session);
PropertyData labelData =
TransientPropertyData.createPropertyData(labels, labelQName,
PropertyType.REFERENCE, false,
@@ -553,7 +553,7 @@
if (vldata != null)
{
- PlainChangesLog changes = new PlainChangesLogImpl(session.getId());
+ PlainChangesLog changes = new PlainChangesLogImpl(session);
changes.add(ItemState.createDeletedState(vldata));
dataManager.getTransactManager().save(changes);
}
@@ -570,15 +570,17 @@
throws RepositoryException
{
checkValid();
-
+
NodeTypeDataManager ntManager = session.getWorkspace().getNodeTypesHolder();
-
- boolean isPrivilegeable = ntManager.isNodeType(Constants.EXO_PRIVILEGEABLE,
versionableNodeData.getPrimaryTypeName(),
- versionableNodeData.getMixinTypeNames());
-
- boolean isOwneable = ntManager.isNodeType(Constants.EXO_OWNEABLE,
versionableNodeData.getPrimaryTypeName(),
- versionableNodeData.getMixinTypeNames());
-
+
+ boolean isPrivilegeable =
+ ntManager.isNodeType(Constants.EXO_PRIVILEGEABLE,
versionableNodeData.getPrimaryTypeName(),
+ versionableNodeData.getMixinTypeNames());
+
+ boolean isOwneable =
+ ntManager.isNodeType(Constants.EXO_OWNEABLE,
versionableNodeData.getPrimaryTypeName(), versionableNodeData
+ .getMixinTypeNames());
+
List<InternalQName> mixinsList = new ArrayList<InternalQName>();
mixinsList.add(Constants.MIX_REFERENCEABLE);
@@ -601,7 +603,7 @@
AccessControlList acl = new AccessControlList(owner, new
ArrayList<AccessControlEntry>(accessList));
InternalQName[] mixins = mixinsList.toArray(new InternalQName[mixinsList.size()]);
-
+
// nt:version
NodeData versionData =
TransientNodeData.createNodeData(nodeData(), new InternalQName(null,
nextVersionName()), Constants.NT_VERSION,
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -145,8 +145,8 @@
* {@inheritDoc}
*/
@Override
- public List<PropertyData> getChildPropertiesData(final NodeData nodeData, final
List<QPathEntryFilter> itemDataFilters)
- throws RepositoryException
+ public List<PropertyData> getChildPropertiesData(final NodeData nodeData,
+ final List<QPathEntryFilter> itemDataFilters) throws RepositoryException
{
if (isSystemDescendant(nodeData.getQPath()) &&
!this.equals(versionDataManager))
{
@@ -285,19 +285,43 @@
// we have pair of logs for system and non-system (this) workspaces
final String pairId = IdGenerator.generate();
- versionLogs.addLog(new PlainChangesLogImpl(vstates,
changes.getSessionId(), changes.getEventType(),
- pairId));
- nonVersionLogs.addLog(new PlainChangesLogImpl(nvstates,
changes.getSessionId(), changes.getEventType(),
- pairId));
+ if (changes.getSession() != null)
+ {
+ versionLogs.addLog(new PlainChangesLogImpl(vstates,
changes.getSession(), changes.getEventType(),
+ pairId));
+ nonVersionLogs.addLog(new PlainChangesLogImpl(nvstates,
changes.getSession(), changes.getEventType(),
+ pairId));
+ }
+ else
+ {
+ versionLogs.addLog(new PlainChangesLogImpl(vstates,
changes.getSessionId(), changes.getEventType(),
+ pairId));
+ nonVersionLogs.addLog(new PlainChangesLogImpl(nvstates,
changes.getSessionId(), changes
+ .getEventType(), pairId));
+ }
}
else
{
- versionLogs.addLog(new PlainChangesLogImpl(vstates,
changes.getSessionId(), changes.getEventType()));
+ if (changes.getSession() != null)
+ {
+ versionLogs.addLog(new PlainChangesLogImpl(vstates,
changes.getSession(), changes.getEventType()));
+ }
+ else
+ {
+ versionLogs.addLog(new PlainChangesLogImpl(vstates,
changes.getSessionId(), changes.getEventType()));
+ }
}
}
else if (nvstates.size() > 0)
{
- nonVersionLogs.addLog(new PlainChangesLogImpl(nvstates,
changes.getSessionId(), changes.getEventType()));
+ if (changes.getSession() != null)
+ {
+ nonVersionLogs.addLog(new PlainChangesLogImpl(nvstates,
changes.getSession(), changes.getEventType()));
+ }
+ else
+ {
+ nonVersionLogs.addLog(new PlainChangesLogImpl(nvstates,
changes.getSessionId(), changes.getEventType()));
+ }
}
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -418,9 +418,19 @@
RepositoryException, IOException
{
// copy state
- PlainChangesLogImpl newLog =
- new PlainChangesLogImpl(new ArrayList<ItemState>(),
changesLog.getSessionId(), changesLog.getEventType(),
- changesLog.getPairId());
+ PlainChangesLogImpl newLog;
+ if (changesLog.getSession() != null)
+ {
+ newLog =
+ new PlainChangesLogImpl(new ArrayList<ItemState>(),
changesLog.getSession(), changesLog.getEventType(),
+ changesLog.getPairId());
+ }
+ else
+ {
+ newLog =
+ new PlainChangesLogImpl(new ArrayList<ItemState>(),
changesLog.getSessionId(),
+ changesLog.getEventType(), changesLog.getPairId());
+ }
for (Iterator<ItemState> iter = changesLog.getAllStates().iterator();
iter.hasNext();)
{
@@ -631,8 +641,8 @@
/**
* {@inheritDoc}
*/
- public boolean getChildNodesDataByPage(final NodeData nodeData, int fromOrderNum, int
limit, List<NodeData> childNodes)
- throws RepositoryException
+ public boolean getChildNodesDataByPage(final NodeData nodeData, int fromOrderNum, int
limit,
+ List<NodeData> childNodes) throws RepositoryException
{
final WorkspaceStorageConnection con = dataContainer.openConnection();
try
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -94,8 +94,14 @@
states.add(new ItemState(copyItemData(change.getData()), change.getState(),
change.isEventFire(), change
.getAncestorToSave(), change.isInternallyCreated(), change.isPersisted(),
change.getOldPath()));
}
-
- newLog.addLog(new PlainChangesLogImpl(states, changes.getSessionId(),
changes.getEventType()));
+ if (changes.getSession() != null)
+ {
+ newLog.addLog(new PlainChangesLogImpl(states, changes.getSession(),
changes.getEventType()));
+ }
+ else
+ {
+ newLog.addLog(new PlainChangesLogImpl(states, changes.getSessionId(),
changes.getEventType()));
+ }
}
storageDataManager.save(newLog);
@@ -145,7 +151,8 @@
/**
* {@inheritDoc}
*/
- public List<NodeData> getChildNodesData(NodeData parent,
List<QPathEntryFilter> patternFilters) throws RepositoryException
+ public List<NodeData> getChildNodesData(NodeData parent,
List<QPathEntryFilter> patternFilters)
+ throws RepositoryException
{
return copyNodes(storageDataManager.getChildNodesData(parent, patternFilters));
}
@@ -166,7 +173,7 @@
{
return storageDataManager.getLastOrderNumber(parent);
}
-
+
/**
* {@inheritDoc}
*/
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -35,6 +35,8 @@
import java.util.List;
import java.util.Map;
+import javax.jcr.Session;
+
/**
* Created by The eXo Platform SAS.<br/> Responsible for managing session changes
log. Relying on
* fact that ItemData inside ItemState SHOULD be TransientItemData
@@ -84,9 +86,9 @@
*
* @param sessionId
*/
- public SessionChangesLog(String sessionId)
+ public SessionChangesLog(Session session)
{
- super(sessionId);
+ super(session);
}
/**
@@ -95,14 +97,14 @@
* @param items
* @param sessionId
*/
- public SessionChangesLog(List<ItemState> items, String sessionId)
+ public SessionChangesLog(List<ItemState> items, Session session)
{
- super(items, sessionId);
+ super(items, session);
for (int i = 0, length = items.size(); i < length; i++)
{
ItemState change = items.get(i);
addItem(change);
- }
+ }
}
/**
@@ -176,9 +178,13 @@
if (childInfo != null)
{
if (item.isDeleted())
+ {
++childInfo[CHILD_NODES_COUNT_INDEX];
+ }
else if (item.isAdded())
+ {
--childInfo[CHILD_NODES_COUNT_INDEX];
+ }
childNodesInfo.put(item.getData().getParentIdentifier(), childInfo);
}
@@ -188,13 +194,17 @@
{
Map<String, ItemState> children =
lastChildNodeStates.get(item.getData().getParentIdentifier());
if (children != null)
+ {
children.remove(item.getData().getIdentifier());
+ }
}
else
{
Map<String, ItemState> children =
lastChildPropertyStates.get(item.getData().getParentIdentifier());
if (children != null)
+ {
children.remove(item.getData().getIdentifier());
+ }
}
}
}
@@ -321,7 +331,8 @@
*/
public PlainChangesLog pushLog(QPath rootPath)
{
- PlainChangesLog cLog = new PlainChangesLogImpl(sessionId);
+ // session instance is always present in SessionChangesLog
+ PlainChangesLog cLog = new PlainChangesLogImpl(session);
if (rootPath.equals(Constants.ROOT_PATH))
{
@@ -419,7 +430,9 @@
{
ItemData item = items.get(i).getData();
if (item.getParentIdentifier().equals(rootIdentifier) ||
item.getIdentifier().equals(rootIdentifier))
+ {
list.add(items.get(i));
+ }
}
return list;
}
@@ -475,11 +488,15 @@
{
// the node
if (items.get(i).isAdded())
+ {
// if a new item - no modify changes can be
return new ArrayList<ItemState>();
+ }
if (!items.get(i).isDeleted())
+ {
changes.put(item.getIdentifier(), items.get(i));
+ }
}
else if (item.getParentIdentifier().equals(rootData.getIdentifier()))
{
@@ -536,7 +553,9 @@
rename = state;
delete = allStates.get(i - 1); // try the fresh delete state
if
(delete.getData().getIdentifier().equals(rename.getData().getIdentifier()))
+ {
return new ItemState[]{delete, rename}; // 3. ok, got it
+ }
}
}
@@ -592,7 +611,9 @@
}
}
else
+ {
byState = true;
+ }
if (byState
&& (isPersisted != null ? istate.isPersisted() == isPersisted :
true)
&& ((orAncestor != null && orAncestor ?
rootPath.isDescendantOf(istate.getData().getQPath()) : true) || rootPath
@@ -639,7 +660,9 @@
}
}
else
+ {
byState = true;
+ }
if (byState && (isPersisted != null ? istate.isPersisted() ==
isPersisted : true)
&& istate.getData().getIdentifier().equals(id))
{
@@ -687,7 +710,9 @@
{
int[] childInfo = childNodesInfo.get(item.getData().getParentIdentifier());
if (childInfo == null)
+ {
childInfo = new int[2];
+ }
if (item.isDeleted())
{
@@ -753,22 +778,34 @@
public boolean equals(Object obj)
{
if (this == obj)
+ {
return true;
+ }
if (obj == null)
+ {
return false;
+ }
if (getClass() != obj.getClass())
+ {
return false;
+ }
IDStateBasedKey other = (IDStateBasedKey)obj;
if (identifier == null)
{
if (other.identifier != null)
+ {
return false;
+ }
}
else if (!identifier.equals(other.identifier))
+ {
return false;
+ }
if (state != other.state)
+ {
return false;
+ }
return true;
}
}
@@ -842,37 +879,55 @@
public boolean equals(Object obj)
{
if (this == obj)
+ {
return true;
+ }
if (obj == null)
+ {
return false;
+ }
if (getClass() != obj.getClass())
+ {
return false;
+ }
ParentIDQPathBasedKey other = (ParentIDQPathBasedKey)obj;
if (name == null)
{
if (other.name != null)
+ {
return false;
+ }
}
else if (!name.getName().equals(other.name.getName())
|| !name.getNamespace().equals(other.name.getNamespace()) || name.getIndex()
!= other.name.getIndex())
+ {
return false;
+ }
if (parentIdentifier == null)
{
if (other.parentIdentifier != null)
+ {
return false;
+ }
}
else if (!parentIdentifier.equals(other.parentIdentifier))
+ {
return false;
+ }
if (itemType == null)
{
if (other.itemType != null)
+ {
return false;
+ }
}
else if (!itemType.equals(other.itemType))
+ {
return false;
+ }
return true;
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/observation/TestSessionsObservation.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/observation/TestSessionsObservation.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/observation/TestSessionsObservation.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -23,6 +23,7 @@
import javax.jcr.Node;
import javax.jcr.RepositoryException;
+import javax.jcr.Session;
import javax.jcr.observation.Event;
public class TestSessionsObservation extends JcrAPIBaseTest
@@ -261,4 +262,26 @@
sessionWs1.getWorkspace().getObservationManager().removeEventListener(listener2);
}
}
+
+ public void testMoveOnClosedSession() throws Exception
+ {
+
+ testRootWs1.addNode("newNode");
+ sessionWs1.save();
+
+ int counter = 0;
+
+ SimpleListener listener = new SimpleListener("testSessionOpen", log,
counter);
+
+ Session sessionWs1ForListener = repository.login(credentials, "ws1");
+
+
sessionWs1ForListener.getWorkspace().getObservationManager().addEventListener(listener,
+ Event.NODE_ADDED | Event.NODE_REMOVED, testRootWs1.getPath() + "/",
false, null, null, false);
+
+ sessionWs1ForListener.logout();
+
+ sessionWs1.logout();
+ sessionWs1.getWorkspace().move(testRootWs1.getPath() + "/newNode",
testRootWs1.getPath() + "/newNode2");
+ assertEquals(2, listener.getCounter());
+ }
}
Added:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/DummySession.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/DummySession.java
(rev 0)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/DummySession.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -0,0 +1,268 @@
+/*
+ * Copyright (C) 2011 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.impl.core;
+
+import org.exoplatform.services.jcr.core.ExtendedSession;
+import org.exoplatform.services.jcr.core.SessionLifecycleListener;
+import org.exoplatform.services.jcr.impl.core.LocationFactory;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.AccessControlException;
+import java.util.Map;
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Credentials;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.InvalidSerializedDataException;
+import javax.jcr.Item;
+import javax.jcr.ItemExistsException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.LoginException;
+import javax.jcr.NamespaceException;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.ValueFactory;
+import javax.jcr.Workspace;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.version.VersionException;
+import javax.transaction.xa.XAResource;
+
+/**
+* @author Nikolay Zamosenchuk
+* @version $Id: DummySession.xml 34360 2009-07-22 23:58:59Z nzamosenchuk $
+*
+*/
+public class DummySession implements ExtendedSession
+{
+ private String sessionId;
+
+ public DummySession(String sessionId)
+ {
+ this.sessionId = sessionId;
+ }
+
+ public String getId()
+ {
+ return sessionId;
+ }
+
+ // do nothing
+ public void exportSystemView(String absPath, OutputStream out, boolean skipBinary,
boolean noRecurse,
+ boolean exportChildVersionHisotry) throws IOException, PathNotFoundException,
RepositoryException
+ {
+ }
+
+ public LocationFactory getLocationFactory()
+ {
+ return null;
+ }
+
+ public Node getNodeByIdentifier(String identifier) throws ItemNotFoundException,
RepositoryException
+ {
+ return null;
+ }
+
+ public long getTimeout()
+ {
+ return 0;
+ }
+
+ public XAResource getXAResource()
+ {
+ return null;
+ }
+
+ public boolean hasExpired()
+ {
+ return false;
+ }
+
+ public void importXML(String parentAbsPath, InputStream in, int uuidBehavior,
Map<String, Object> context)
+ throws IOException, PathNotFoundException, ItemExistsException,
ConstraintViolationException,
+ InvalidSerializedDataException, RepositoryException
+ {
+ }
+
+ public void registerLifecycleListener(SessionLifecycleListener listener)
+ {
+ }
+
+ public void setTimeout(long timeout)
+ {
+ }
+
+ public void addLockToken(String lt)
+ {
+ }
+
+ public void checkPermission(String absPath, String actions) throws
AccessControlException, RepositoryException
+ {
+ }
+
+ public void exportDocumentView(String absPath, ContentHandler contentHandler, boolean
skipBinary, boolean noRecurse)
+ throws PathNotFoundException, SAXException, RepositoryException
+ {
+ }
+
+ public void exportDocumentView(String absPath, OutputStream out, boolean skipBinary,
boolean noRecurse)
+ throws IOException, PathNotFoundException, RepositoryException
+ {
+ }
+
+ public void exportSystemView(String absPath, ContentHandler contentHandler, boolean
skipBinary, boolean noRecurse)
+ throws PathNotFoundException, SAXException, RepositoryException
+ {
+ }
+
+ public void exportSystemView(String absPath, OutputStream out, boolean skipBinary,
boolean noRecurse)
+ throws IOException, PathNotFoundException, RepositoryException
+ {
+ }
+
+ public Object getAttribute(String name)
+ {
+ return null;
+ }
+
+ public String[] getAttributeNames()
+ {
+ return null;
+ }
+
+ public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior)
throws PathNotFoundException,
+ ConstraintViolationException, VersionException, LockException, RepositoryException
+ {
+ return null;
+ }
+
+ public Item getItem(String absPath) throws PathNotFoundException, RepositoryException
+ {
+ return null;
+ }
+
+ public String[] getLockTokens()
+ {
+ return null;
+ }
+
+ public String getNamespacePrefix(String uri) throws NamespaceException,
RepositoryException
+ {
+ return null;
+ }
+
+ public String[] getNamespacePrefixes() throws RepositoryException
+ {
+ return null;
+ }
+
+ public String getNamespaceURI(String prefix) throws NamespaceException,
RepositoryException
+ {
+ return null;
+ }
+
+ public Node getNodeByUUID(String uuid) throws ItemNotFoundException,
RepositoryException
+ {
+ return null;
+ }
+
+ public Repository getRepository()
+ {
+ return null;
+ }
+
+ public Node getRootNode() throws RepositoryException
+ {
+ return null;
+ }
+
+ public String getUserID()
+ {
+ return null;
+ }
+
+ public ValueFactory getValueFactory() throws UnsupportedRepositoryOperationException,
RepositoryException
+ {
+ return null;
+ }
+
+ public Workspace getWorkspace()
+ {
+ return null;
+ }
+
+ public boolean hasPendingChanges() throws RepositoryException
+ {
+ return false;
+ }
+
+ public Session impersonate(Credentials credentials) throws LoginException,
RepositoryException
+ {
+ return null;
+ }
+
+ public void importXML(String parentAbsPath, InputStream in, int uuidBehavior) throws
IOException,
+ PathNotFoundException, ItemExistsException, ConstraintViolationException,
VersionException,
+ InvalidSerializedDataException, LockException, RepositoryException
+ {
+ }
+
+ public boolean isLive()
+ {
+ return false;
+ }
+
+ public boolean itemExists(String absPath) throws RepositoryException
+ {
+ return false;
+ }
+
+ public void logout()
+ {
+ }
+
+ public void move(String srcAbsPath, String destAbsPath) throws ItemExistsException,
PathNotFoundException,
+ VersionException, ConstraintViolationException, LockException, RepositoryException
+ {
+ }
+
+ public void refresh(boolean keepChanges) throws RepositoryException
+ {
+ }
+
+ public void removeLockToken(String lt)
+ {
+ }
+
+ public void save() throws AccessDeniedException, ItemExistsException,
ConstraintViolationException,
+ InvalidItemStateException, VersionException, LockException,
NoSuchNodeTypeException, RepositoryException
+ {
+ }
+
+ public void setNamespacePrefix(String prefix, String uri) throws NamespaceException,
RepositoryException
+ {
+ }
+}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestItemDataChangesLog.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestItemDataChangesLog.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestItemDataChangesLog.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -70,7 +70,7 @@
public void testBasicOperations() throws Exception
{
- SessionChangesLog cLog = new SessionChangesLog("s1");
+ SessionChangesLog cLog = new SessionChangesLog(new DummySession("s1"));
cLog.add(ItemState.createAddedState(data1));
cLog.add(ItemState.createAddedState(data2));
cLog.add(ItemState.createDeletedState(data2));
@@ -92,7 +92,7 @@
public void testSessionOperations() throws Exception
{
- SessionChangesLog cLog = new SessionChangesLog("s1");
+ SessionChangesLog cLog = new SessionChangesLog(new DummySession("s1"));
TransientNodeData d1 =
TransientNodeData.createNodeData(data1, new InternalQName(null,
"testSessionOperations"), new InternalQName(
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLogTest.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLogTest.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLogTest.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -20,10 +20,10 @@
import org.exoplatform.services.jcr.JcrImplBaseTest;
import org.exoplatform.services.jcr.dataflow.ItemState;
-import org.exoplatform.services.jcr.dataflow.persistent.PersistedPropertyData;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.core.DummySession;
import org.exoplatform.services.jcr.impl.core.NodeImpl;
import org.exoplatform.services.jcr.impl.core.SessionDataManager;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
@@ -120,7 +120,7 @@
try
{
userSession = (SessionImpl)frepository.login(fcredentials,
"ws");
- chlog[0] = new SessionChangesLogInfo(new
SessionChangesLog(userSession.getId()), userSession.getId());
+ chlog[0] = new SessionChangesLogInfo(new SessionChangesLog(userSession),
userSession.getId());
}
catch (RepositoryException e)
{
@@ -148,7 +148,7 @@
public void testSameSession()
{
- SessionChangesLog chlog = new SessionChangesLog(session.getId());
+ SessionChangesLog chlog = new SessionChangesLog(session);
assertEquals("Session must be same as given id owns", session,
getRegisteredSession(chlog.getSessionId()));
}
@@ -156,7 +156,7 @@
{
String id = IdGenerator.generate();
- SessionChangesLog chlog = new SessionChangesLog(id);
+ SessionChangesLog chlog = new SessionChangesLog(new DummySession(id));
assertNull("No session should be linked to the log",
getRegisteredSession(chlog.getSessionId()));
}
@@ -248,7 +248,7 @@
public void testAddRootChanges() throws Exception
{
- SessionChangesLog changesLog = new SessionChangesLog(session.getId());
+ SessionChangesLog changesLog = new SessionChangesLog(session);
try
{
changesLog.add(new ItemState(new TransientPropertyData(Constants.ROOT_PATH,
Constants.ROOT_UUID, 0,
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestJCRVSReadWrite.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestJCRVSReadWrite.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestJCRVSReadWrite.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -147,7 +147,9 @@
path = resource.setProperty("jcr:data", vals).getPath();
}
else
+ {
path = resource.setProperty("jcr:data", fBLOB1).getPath();
+ }
resource.setProperty("jcr:mimeType",
"application/x-octet-stream");
resource.setProperty("jcr:lastModified", Calendar.getInstance());
testRoot.save();
@@ -191,7 +193,7 @@
{
try
{
- SessionChangesLog changes = new
SessionChangesLog(((NodeImpl)testRoot).getSession().getId());
+ SessionChangesLog changes = new
SessionChangesLog(((NodeImpl)testRoot).getSession());
TransientNodeData ntfile =
TransientNodeData.createNodeData(rootData,
InternalQName.parse("[]blob" + i), Constants.NT_FILE);
@@ -218,7 +220,9 @@
data.add(new TransientValueData(fBLOB2));
}
else
+ {
data.add(new TransientValueData(fBLOB1));
+ }
TransientPropertyData resData =
TransientPropertyData.createPropertyData(res, Constants.JCR_DATA,
PropertyType.BINARY, data.size() > 1,
@@ -259,7 +263,7 @@
{
final DataManager dm =
((NodeImpl)testRoot).getSession().getTransientNodesManager().getTransactManager().getStorageDataManager();
- final SessionChangesLog changes = new
SessionChangesLog(((NodeImpl)testRoot).getSession().getId());
+ final SessionChangesLog changes = new
SessionChangesLog(((NodeImpl)testRoot).getSession());
class Remover
{
@@ -301,12 +305,18 @@
}
if (item == null)
+ {
break;
+ }
if (item.isNode())
+ {
parent = (NodeData)item;
+ }
else if (i < relPathEntries.length - 1)
+ {
throw new IllegalPathException("Path can not contains a property as the
intermediate element");
+ }
}
return item;
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/version/BaseVersionImplTest.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/version/BaseVersionImplTest.java 2011-09-28
07:02:50 UTC (rev 4990)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/version/BaseVersionImplTest.java 2011-09-28
08:31:57 UTC (rev 4991)
@@ -223,11 +223,11 @@
versionedVersionHistoryData = new ArrayList<ValueData>();
versionedVersionHistoryData.add(new
TestTransientValueData(versionedVersionHistoryUuid.getBytes(), 0));
- changesLog = new SessionChangesLog(session.getId());
+ changesLog = new SessionChangesLog(session);
ntManager = (NodeTypeManagerImpl)session.getWorkspace().getNodeTypeManager();
- SessionChangesLog initChanges = new SessionChangesLog(session.getId());
+ SessionChangesLog initChanges = new SessionChangesLog(session);
NodeData wsRoot = (NodeData)((NodeImpl)session.getRootNode()).getData();
testRoot =
@@ -267,7 +267,7 @@
public void createVersionable(int testCase) throws Exception
{
- versionableLog = new SessionChangesLog(session.getId());
+ versionableLog = new SessionChangesLog(session);
// target node
versionable =