Index: src/main/java/org/apache/jackrabbit/core/cluster/ChangeLogRecord.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/cluster/ChangeLogRecord.java (revision 723728) +++ src/main/java/org/apache/jackrabbit/core/cluster/ChangeLogRecord.java (working copy) @@ -63,6 +63,11 @@ static final char EVENT_IDENTIFIER = 'E'; /** + * Identifier: USER DATA. + */ + static final char USER_DATA_IDENTIFIER = 'U'; + + /** * Operation type: added. */ private static final int ADDED = 1; @@ -93,6 +98,11 @@ private List events; /** + * The user data. + */ + private String userData; + + /** * First identifier read. */ private int identifier; @@ -110,14 +120,17 @@ * @param record record * @param workspace workspace * @param timestamp when the changes for this record were persisted. + * @param userData the user data associated with these changes. */ public ChangeLogRecord(ChangeLog changes, List events, - Record record, String workspace, long timestamp) { + Record record, String workspace, + long timestamp, String userData) { super(record, workspace); this.changes = changes; this.events = events; this.timestamp = timestamp; + this.userData = userData; } /** @@ -146,6 +159,9 @@ case DATE_IDENTIFIER: readTimestampRecord(); break; + case USER_DATA_IDENTIFIER: + readUserDataRecord(); + break; case NODE_IDENTIFIER: readNodeRecord(); break; @@ -182,6 +198,15 @@ } /** + * Reads the user data record. + * + * @throws JournalException if an error occurs. + */ + private void readUserDataRecord() throws JournalException { + userData = record.readString(); + } + + /** * Read a node record. * * @throws JournalException if an error occurs @@ -313,6 +338,7 @@ */ protected void doWrite() throws JournalException { writeTimestampRecord(); + writeUserDataRecord(); Iterator deletedStates = changes.deletedStates(); while (deletedStates.hasNext()) { ItemState state = (ItemState) deletedStates.next(); @@ -359,6 +385,18 @@ } /** + * Writes the user data record. + * + * @throws JournalException if an error occurs. + */ + private void writeUserDataRecord() throws JournalException { + if (userData != null) { + record.writeChar(USER_DATA_IDENTIFIER); + record.writeString(userData); + } + } + + /** * Write a node record * * @param operation operation @@ -445,4 +483,13 @@ public long getTimestamp() { return timestamp; } + + /** + * Returns the user data. + * + * @return the user data. + */ + public String getUserData() { + return userData; + } } Index: src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java (revision 723728) +++ src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java (working copy) @@ -615,7 +615,8 @@ try { ChangeLogRecord clr = new ChangeLogRecord(changes, events, - record, workspace, update.getTimestamp()); + record, workspace, update.getTimestamp(), + update.getUserData()); clr.write(); succeeded = true; } catch (JournalException e) { @@ -849,8 +850,8 @@ } } try { - listener.externalUpdate(record.getChanges(), - record.getEvents(), record.getTimestamp()); + listener.externalUpdate(record.getChanges(), record.getEvents(), + record.getTimestamp(), record.getUserData()); } catch (RepositoryException e) { String msg = "Unable to deliver update events: " + e.getMessage(); log.error(msg); Index: src/main/java/org/apache/jackrabbit/core/cluster/Update.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/cluster/Update.java (revision 723728) +++ src/main/java/org/apache/jackrabbit/core/cluster/Update.java (working copy) @@ -64,4 +64,10 @@ */ long getTimestamp(); + /** + * Returns the user data associated with this update. + * + * @return the user data associated with this update. + */ + String getUserData(); } Index: src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventListener.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventListener.java (revision 723728) +++ src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventListener.java (working copy) @@ -31,9 +31,10 @@ * @param changes external changes containing only node and property ids. * @param events events to deliver * @param timestamp when the change occured. + * @param userData the user data associated with this update. * @throws RepositoryException if the update cannot be processed */ - void externalUpdate(ChangeLog changes, List events, long timestamp) + void externalUpdate(ChangeLog changes, List events, long timestamp, String userData) throws RepositoryException; } Index: src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java (revision 723728) +++ src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java (working copy) @@ -155,7 +155,8 @@ NodeImpl child = root.getNode(ntName); List events = new ArrayList(); recursiveAdd(events, root, child); - obsDispatcher.dispatch(events, systemSession, NODE_TYPES_PATH); + obsDispatcher.dispatch(events, systemSession, + NODE_TYPES_PATH, null); } } catch (RepositoryException e) { log.error("Unable to index new nodetype: " + e.toString()); @@ -182,7 +183,8 @@ NodeImpl child = root.getNode(ntName); List events = new ArrayList(); recursiveRemove(events, root, child); - obsDispatcher.dispatch(events, systemSession, NODE_TYPES_PATH); + obsDispatcher.dispatch(events, systemSession, + NODE_TYPES_PATH, null); } if (virtProvider != null) { // allow provider to update Index: src/main/java/org/apache/jackrabbit/core/observation/DelegatingObservationDispatcher.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/observation/DelegatingObservationDispatcher.java (revision 723728) +++ src/main/java/org/apache/jackrabbit/core/observation/DelegatingObservationDispatcher.java (working copy) @@ -25,6 +25,8 @@ import java.util.HashSet; import java.util.List; +import javax.jcr.RepositoryException; + /** * This Class implements an observation dispatcher, that delegates events to * a set of underlying dispatchers. @@ -73,7 +75,14 @@ */ public EventStateCollection createEventStateCollection(SessionImpl session, Path pathPrefix) { - return new EventStateCollection(this, session, pathPrefix); + String userData = null; + try { + userData = ((ObservationManagerImpl) session.getWorkspace().getObservationManager()).getUserData(); + } catch (RepositoryException e) { + // should never happen because this + // implementation supports observation + } + return new EventStateCollection(this, session, pathPrefix, userData); } //------------------------------------------------------< EventDispatcher > @@ -96,7 +105,8 @@ * {@inheritDoc} */ void dispatchEvents(EventStateCollection events) { - dispatch(events.getEvents(), events.getSession(), events.getPathPrefix()); + dispatch(events.getEvents(), events.getSession(), + events.getPathPrefix(), events.getUserData()); } /** @@ -107,8 +117,10 @@ * @param eventList list of events * @param session current session * @param pathPrefix event path prefix + * @param userData the user data */ - public void dispatch(List eventList, SessionImpl session, Path pathPrefix) { + public void dispatch(List eventList, SessionImpl session, + Path pathPrefix, String userData) { ObservationDispatcher[] disp; synchronized (dispatchers) { disp = (ObservationDispatcher[]) dispatchers.toArray( @@ -116,7 +128,8 @@ } for (int i = 0; i < disp.length; i++) { EventStateCollection events = - new EventStateCollection(disp[i], session, pathPrefix); + new EventStateCollection(disp[i], session, + pathPrefix, userData); try { events.addAll(eventList); events.prepare(); Index: src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java (revision 723728) +++ src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java (working copy) @@ -239,7 +239,7 @@ } // check if filtered iterator has at least one event EventIterator it = new FilteredEventIterator(events.iterator(), - events.getTimestamp(), filter, denied); + events.getTimestamp(), events.getUserData(), filter, denied); if (it.hasNext()) { listener.onEvent(it); } else { Index: src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java (revision 723728) +++ src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java (working copy) @@ -55,6 +55,11 @@ private final long timestamp; /** + * The user data associated with this event. + */ + private final String userData; + + /** * Cached String value of this Event instance. */ private String stringValue; @@ -67,11 +72,14 @@ * where this Event will be delivered to. * @param eventState the underlying EventState. * @param timestamp the time when the change occured that caused this event. + * @param userData the user data associated with this event. */ - EventImpl(SessionImpl session, EventState eventState, long timestamp) { + EventImpl(SessionImpl session, EventState eventState, + long timestamp, String userData) { this.session = session; this.eventState = eventState; this.timestamp = timestamp; + this.userData = userData; } //---------------------------------------------------------------< Event > @@ -104,6 +112,13 @@ return timestamp; } + /** + * {@inheritDoc} + */ + public String getUserData() { + return userData; + } + //-----------------------------------------------------------< EventImpl > /** @@ -177,6 +192,8 @@ } sb.append(", ").append(EventState.valueOf(getType())).append(": "); sb.append(", UserId: ").append(getUserID()); + sb.append(", Timestamp: ").append(timestamp); + sb.append(", UserData: ").append(userData); stringValue = sb.toString(); } return stringValue; @@ -186,7 +203,11 @@ * @see Object#hashCode() */ public int hashCode() { - return eventState.hashCode() ^ session.hashCode(); + int h = eventState.hashCode() ^ new Long(timestamp).hashCode() ^ session.hashCode(); + if (userData != null) { + h = h ^ userData.hashCode(); + } + return h; } /** @@ -209,8 +230,26 @@ if (obj instanceof EventImpl) { EventImpl other = (EventImpl) obj; return this.eventState.equals(other.eventState) - && this.session.equals(other.session); + && this.session.equals(other.session) + && this.timestamp == other.timestamp + && equals(this.userData, other.userData); } return false; } + + /** + * Returns true if the objects are equal or both are + * null; otherwise returns false. + * + * @param o1 an object. + * @param o2 another object. + * @return true if equal; false otherwise. + */ + private static boolean equals(Object o1, Object o2) { + if (o1 == null) { + return o2 == null; + } else { + return o1.equals(o2); + } + } } Index: src/main/java/org/apache/jackrabbit/core/observation/EventJournalImpl.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/observation/EventJournalImpl.java (revision 723728) +++ src/main/java/org/apache/jackrabbit/core/observation/EventJournalImpl.java (working copy) @@ -270,7 +270,7 @@ List events = record.getEvents(); if (!events.isEmpty()) { EventBundle bundle = new EventBundle(events, - record.getTimestamp(), filter); + record.getTimestamp(), record.getUserData(), filter); if (bundle.events.hasNext()) { // only queue bundle if there is an event eventBundleBuffer.add(bundle); @@ -400,13 +400,15 @@ * * @param eventStates the {@link EventState}s that belong to this bundle. * @param timestamp the timestamp when the events were created. + * @param userData the user data associated with this event. * @param filter the event filter. */ private EventBundle(List eventStates, long timestamp, + String userData, EventFilter filter) { this.events = new FilteredEventIterator(eventStates.iterator(), - timestamp, filter, Collections.EMPTY_SET); + timestamp, userData, filter, Collections.EMPTY_SET); this.timestamp = timestamp; } } Index: src/main/java/org/apache/jackrabbit/core/observation/EventState.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/observation/EventState.java (revision 723728) +++ src/main/java/org/apache/jackrabbit/core/observation/EventState.java (working copy) @@ -633,7 +633,7 @@ } else if (eventType == Event.PROPERTY_ADDED) { return "PropertyAdded"; } else if (eventType == Event.PROPERTY_CHANGED) { - return "PropertyOperation"; + return "PropertyChanged"; } else if (eventType == Event.PROPERTY_REMOVED) { return "PropertyRemoved"; } else { Index: src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java (revision 723728) +++ src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java (working copy) @@ -93,6 +93,11 @@ private long timestamp = System.currentTimeMillis(); /** + * The user data attached to this event state collection. + */ + private String userData; + + /** * Creates a new empty EventStateCollection. *

* Because the item state manager in {@link #createEventStates} may represent @@ -104,13 +109,16 @@ * @param session the session that created these events. * @param pathPrefix the path to prefix the event paths or null * if no prefix should be used. + * @param userData the user data attached to this event state collection. */ public EventStateCollection(EventDispatcher dispatcher, SessionImpl session, - Path pathPrefix) { + Path pathPrefix, + String userData) { this.dispatcher = dispatcher; this.session = session; this.pathPrefix = pathPrefix; + this.userData = userData; } /** @@ -480,6 +488,24 @@ } /** + * @return the user data attached to this event state collection. + */ + public String getUserData() { + return userData; + } + + /** + * Sets the user data for this event state collection. + * + * @param userData the user data. + */ + public void setUserData(String userData) { + this.userData = userData; + } + + //----------------------------< internal >---------------------------------- + + /** * Resolves the node type name in node into a {@link javax.jcr.nodetype.NodeType} * object using the {@link javax.jcr.nodetype.NodeTypeManager} of session. * Index: src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java (revision 723728) +++ src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java (working copy) @@ -68,10 +68,16 @@ private long timestamp; /** + * The user data associated with these events. + */ + private final String userData; + + /** * Creates a new FilteredEventIterator. * * @param eventStates an iterator over unfiltered {@link EventState}s. * @param timestamp the time when the event were created. + * @param userData the user data associated with these events. * @param filter only event that pass the filter will be dispatched to the * event listener. * @param denied Set of ItemIds of denied ItemStates @@ -80,12 +86,14 @@ */ public FilteredEventIterator(Iterator eventStates, long timestamp, + String userData, EventFilter filter, Set denied) { this.actualEvents = eventStates; this.filter = filter; this.denied = denied; this.timestamp = timestamp; + this.userData = userData; fetchNext(); } @@ -167,7 +175,7 @@ if (denied == null || !denied.contains(state.getTargetId())) { try { next = filter.blocks(state) ? null : new EventImpl( - filter.getSession(), state, timestamp); + filter.getSession(), state, timestamp, userData); } catch (RepositoryException e) { log.error("Exception while applying filter.", e); } Index: src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java (revision 723728) +++ src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java (working copy) @@ -59,6 +59,11 @@ */ private final ObservationDispatcher dispatcher; + /** + * The currently set user data. + */ + private String userData; + static { // preload EventListenerIteratorImpl to prevent classloader issues during shutdown EventListenerIteratorImpl.class.hashCode(); @@ -131,6 +136,20 @@ } /** + * {@inheritDoc} + */ + public void setUserData(String userData) throws RepositoryException { + this.userData = userData; + } + + /** + * @return the currently set user data. + */ + String getUserData() { + return userData; + } + + /** * Unregisters all EventListeners. */ public void dispose() { @@ -210,6 +229,6 @@ * which is attached to this ObservationManager instance. */ public EventStateCollection createEventStateCollection() { - return new EventStateCollection(dispatcher, session, null); + return new EventStateCollection(dispatcher, session, null, userData); } } Index: src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java (revision 723728) +++ src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java (working copy) @@ -2098,10 +2098,11 @@ */ public void externalUpdate(ChangeLog external, List events, - long timestamp) throws RepositoryException { + long timestamp, + String userData) throws RepositoryException { try { EventStateCollection esc = new EventStateCollection( - getObservationDispatcher(), null, null); + getObservationDispatcher(), null, null, userData); esc.addAll(events); esc.setTimestamp(timestamp); Index: src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java (revision 723728) +++ src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java (working copy) @@ -846,6 +846,10 @@ return timestamp; } + public String getUserData() { + return events.getUserData(); + } + /** * Updates the target node references collections based on the * modifications in the change log (i.e. added/removed/modified Index: src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java (revision 723728) +++ src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java (working copy) @@ -494,11 +494,13 @@ /** * {@inheritDoc} */ - public void externalUpdate(ChangeLog changes, List events, long timestamp) + public void externalUpdate(ChangeLog changes, List events, + long timestamp, String userData) throws RepositoryException { EventStateCollection esc = getEscFactory().createEventStateCollection(null); esc.addAll(events); esc.setTimestamp(timestamp); + esc.setUserData(userData); sharedStateMgr.externalUpdate(changes, esc); } Index: src/test/java/org/apache/jackrabbit/core/cluster/SimpleEventListener.java =================================================================== --- src/test/java/org/apache/jackrabbit/core/cluster/SimpleEventListener.java (revision 723728) +++ src/test/java/org/apache/jackrabbit/core/cluster/SimpleEventListener.java (working copy) @@ -412,10 +412,11 @@ /** * {@inheritDoc} */ - public void externalUpdate(ChangeLog changes, List events, long timestamp) + public void externalUpdate(ChangeLog changes, List events, + long timestamp, String userData) throws RepositoryException { - clusterEvents.add(new UpdateEvent(changes, events, timestamp)); + clusterEvents.add(new UpdateEvent(changes, events, timestamp, userData)); } @@ -445,16 +446,24 @@ private final long timestamp; /** + * The user data associated with this update. + */ + private final String userData; + + /** * Create a new instance of this class. * * @param changes change log * @param events list of EventStates * @param timestamp time when the changes in this event occured. + * @param userData the user data associated with this update. */ - public UpdateEvent(ChangeLog changes, List events, long timestamp) { + public UpdateEvent(ChangeLog changes, List events, + long timestamp, String userData) { this.changes = changes; this.events = events; this.timestamp = timestamp; + this.userData = userData; } /** @@ -482,6 +491,10 @@ return timestamp; } + public String getUserData() { + return userData; + } + /** * {@inheritDoc} */ @@ -500,7 +513,11 @@ * {@inheritDoc} */ public int hashCode() { - return changes.hashCode() ^ events.hashCode() ^ (int) (timestamp ^ (timestamp >>> 32)); + int h = changes.hashCode() ^ events.hashCode() ^ (int) (timestamp ^ (timestamp >>> 32)); + if (userData != null) { + h = h ^ userData.hashCode(); + } + return h; } /** @@ -511,7 +528,8 @@ UpdateEvent other = (UpdateEvent) obj; return SimpleEventListener.equals(changes, other.changes) && SimpleEventListener.equals(events, other.events) && - timestamp == other.timestamp; + timestamp == other.timestamp && + SimpleEventListener.equals(userData, other.userData); } return false; } Index: src/test/java/org/apache/jackrabbit/core/cluster/UpdateEventFactory.java =================================================================== --- src/test/java/org/apache/jackrabbit/core/cluster/UpdateEventFactory.java (revision 723728) +++ src/test/java/org/apache/jackrabbit/core/cluster/UpdateEventFactory.java (working copy) @@ -116,7 +116,7 @@ events.add(createEventState(p2, n2, Event.PROPERTY_REMOVED)); events.add(createEventState(n3, Event.NODE_REMOVED, "{}n3")); - return new UpdateEvent(changes, events, System.currentTimeMillis()); + return new UpdateEvent(changes, events, System.currentTimeMillis(), "user-data"); } Index: src/test/java/org/apache/jackrabbit/core/observation/AbstractObservationTest.java =================================================================== --- src/test/java/org/apache/jackrabbit/core/observation/AbstractObservationTest.java (revision 0) +++ src/test/java/org/apache/jackrabbit/core/observation/AbstractObservationTest.java (revision 0) @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.core.observation; + +import javax.jcr.observation.Event; + +/** + * AbstractObservationTest is a base class with utility methods + * for observation related tests. + */ +public class AbstractObservationTest extends org.apache.jackrabbit.test.api.observation.AbstractObservationTest { + + protected static final int ALL_TYPES = Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED; + + /** + * @return the observation manager implementation. + */ + protected ObservationManagerImpl getObservationManager() { + // TODO: remove when JCR 2.0 is final + return (ObservationManagerImpl) obsMgr; + } + + /** + * Returns the user data for the given event. + * + * @param e the event. + * @return the user data for the given event. + */ + protected static String getUserData(Event e) { + // TODO: remove when JCR 2.0 is final + return ((EventImpl) e).getUserData(); + } +} Property changes on: src\test\java\org\apache\jackrabbit\core\observation\AbstractObservationTest.java ___________________________________________________________________ Added: svn:eol-style + native Index: src/test/java/org/apache/jackrabbit/core/observation/EventJournalTest.java =================================================================== --- src/test/java/org/apache/jackrabbit/core/observation/EventJournalTest.java (revision 723728) +++ src/test/java/org/apache/jackrabbit/core/observation/EventJournalTest.java (working copy) @@ -25,17 +25,14 @@ import javax.jcr.Session; import javax.jcr.observation.Event; -import org.apache.jackrabbit.test.AbstractJCRTest; import org.apache.jackrabbit.core.WorkspaceImpl; import org.apache.jackrabbit.api.jsr283.observation.EventJournal; /** * EventJournalTest performs EventJournal tests. */ -public class EventJournalTest extends AbstractJCRTest { +public class EventJournalTest extends AbstractObservationTest { - private static final int ALL_TYPES = Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED; - private EventJournal journal; protected void setUp() throws Exception { @@ -178,6 +175,19 @@ checkJournal(new String[]{n2.getPath()}, new String[]{n1.getPath()}); } + public void testUserData() throws RepositoryException { + testRootNode.addNode(nodeName1); + getObservationManager().setUserData("test"); + + journal = getEventJournal(ALL_TYPES, testRoot, true, null, null); + journal.skipTo(System.currentTimeMillis()); + + superuser.save(); + + assertTrue("no more events", journal.hasNext()); + assertEquals("Wrong user data", "test", getUserData(journal.nextEvent())); + } + //-------------------------------< internal >------------------------------- private EventJournal getEventJournal(int eventTypes, @@ -186,6 +196,7 @@ String[] uuid, String[] nodeTypeName) throws RepositoryException { + // TODO: remove cast when JCR 2.0 is final return ((WorkspaceImpl) superuser.getWorkspace()).getEventJournal( eventTypes, absPath, isDeep, uuid, nodeTypeName); } Index: src/test/java/org/apache/jackrabbit/core/observation/TestAll.java =================================================================== --- src/test/java/org/apache/jackrabbit/core/observation/TestAll.java (revision 723728) +++ src/test/java/org/apache/jackrabbit/core/observation/TestAll.java (working copy) @@ -41,6 +41,7 @@ suite.addTestSuite(VersionEventsTest.class); suite.addTestSuite(MoveInPlaceTest.class); suite.addTestSuite(EventJournalTest.class); + suite.addTestSuite(UserDataTest.class); return suite; } Index: src/test/java/org/apache/jackrabbit/core/observation/UserDataTest.java =================================================================== --- src/test/java/org/apache/jackrabbit/core/observation/UserDataTest.java (revision 0) +++ src/test/java/org/apache/jackrabbit/core/observation/UserDataTest.java (revision 0) @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.core.observation; + +import javax.jcr.RepositoryException; +import javax.jcr.Node; +import javax.jcr.observation.Event; + +import org.apache.jackrabbit.test.api.observation.EventResult; + +/** + * UserDataTest... + */ +public class UserDataTest extends AbstractObservationTest { + + public void testSave() throws RepositoryException { + runWithUserData(new Callable() { + public void call() throws RepositoryException { + testRootNode.addNode(nodeName1, testNodeType); + testRootNode.save(); + } + }, ALL_TYPES); + } + + public void testWorkspaceOperation() throws RepositoryException { + testRootNode.addNode(nodeName1); + testRootNode.save(); + + runWithUserData(new Callable() { + public void call() throws RepositoryException { + String src = testRoot + "/" + nodeName1; + String dest = testRoot + "/" + nodeName2; + superuser.getWorkspace().move(src, dest); + } + }, ALL_TYPES); + } + + public void testVersioning() throws RepositoryException { + final Node n1 = testRootNode.addNode(nodeName1); + n1.addMixin(mixVersionable); + testRootNode.save(); + + runWithUserData(new Callable() { + public void call() throws RepositoryException { + n1.checkin(); + } + }, Event.NODE_ADDED); // get events for added version node + } + + protected void runWithUserData(Callable c, int eventTypes) + throws RepositoryException { + EventResult result = new EventResult(log); + addEventListener(result, eventTypes); + getObservationManager().setUserData("test"); + + c.call(); + + removeEventListener(result); + + Event[] events = result.getEvents(DEFAULT_WAIT_TIMEOUT); + assertTrue("no events returned", events.length > 0); + for (int i = 0; i < events.length; i++) { + assertEquals("Wrong user data", "test", getUserData(events[i])); + } + } + + public interface Callable { + + public void call() throws RepositoryException; + } +} Property changes on: src\test\java\org\apache\jackrabbit\core\observation\UserDataTest.java ___________________________________________________________________ Added: svn:eol-style + native