jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r770224 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: WorkspaceImpl.java observation/ObservationManagerImpl.java
Date Thu, 30 Apr 2009 13:49:17 GMT
Author: jukka
Date: Thu Apr 30 13:49:17 2009
New Revision: 770224

URL: http://svn.apache.org/viewvc?rev=770224&view=rev
Log:
JCR-1849: JSR 283: EventJournal

Adjust the EventJournal implementation to the JCR 2.0 PFD version.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java?rev=770224&r1=770223&r2=770224&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
Thu Apr 30 13:49:17 2009
@@ -16,61 +16,55 @@
  */
 package org.apache.jackrabbit.core;
 
-import org.apache.jackrabbit.api.JackrabbitWorkspace;
-import javax.jcr.observation.EventJournal;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.observation.ObservationManager;
+import javax.jcr.query.QueryManager;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionException;
+import javax.jcr.version.VersionHistory;
 import javax.jcr.version.VersionManager;
+
+import org.apache.jackrabbit.api.JackrabbitWorkspace;
+import org.apache.jackrabbit.commons.AbstractWorkspace;
 import org.apache.jackrabbit.core.config.WorkspaceConfig;
 import org.apache.jackrabbit.core.lock.LockManager;
 import org.apache.jackrabbit.core.lock.SessionLockManager;
 import org.apache.jackrabbit.core.observation.EventStateCollection;
 import org.apache.jackrabbit.core.observation.EventStateCollectionFactory;
 import org.apache.jackrabbit.core.observation.ObservationManagerImpl;
-import org.apache.jackrabbit.core.observation.EventJournalImpl;
-import org.apache.jackrabbit.core.observation.EventFilter;
 import org.apache.jackrabbit.core.query.QueryManagerImpl;
+import org.apache.jackrabbit.core.retention.RetentionRegistry;
 import org.apache.jackrabbit.core.state.LocalItemStateManager;
 import org.apache.jackrabbit.core.state.SharedItemStateManager;
 import org.apache.jackrabbit.core.version.DateVersionSelector;
+import org.apache.jackrabbit.core.version.JcrVersionManagerImpl;
 import org.apache.jackrabbit.core.version.VersionImpl;
 import org.apache.jackrabbit.core.version.VersionSelector;
-import org.apache.jackrabbit.core.version.JcrVersionManagerImpl;
 import org.apache.jackrabbit.core.xml.ImportHandler;
 import org.apache.jackrabbit.core.xml.Importer;
 import org.apache.jackrabbit.core.xml.WorkspaceImporter;
-import org.apache.jackrabbit.core.cluster.ClusterNode;
-import org.apache.jackrabbit.core.security.principal.AdminPrincipal;
-import org.apache.jackrabbit.core.retention.RetentionRegistry;
-import org.apache.jackrabbit.commons.AbstractWorkspace;
-import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.InputSource;
 
-import javax.jcr.AccessDeniedException;
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.ItemExistsException;
-import javax.jcr.ItemNotFoundException;
-import javax.jcr.NamespaceRegistry;
-import javax.jcr.NoSuchWorkspaceException;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.lock.LockException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NodeTypeManager;
-import javax.jcr.observation.ObservationManager;
-import javax.jcr.query.QueryManager;
-import javax.jcr.version.Version;
-import javax.jcr.version.VersionException;
-import javax.jcr.version.VersionHistory;
-import javax.security.auth.Subject;
-
-import java.util.HashMap;
-import java.util.Iterator;
-
 /**
  * A <code>WorkspaceImpl</code> ...
  */
@@ -787,7 +781,9 @@
             try {
                 obsMgr = new ObservationManagerImpl(
                         rep.getObservationDispatcher(wspConfig.getName()),
-                        session, session.getItemManager());
+                        session,
+                        session.getItemManager(),
+                        rep.getClusterNode());
             } catch (NoSuchWorkspaceException nswe) {
                 // should never get here
                 String msg = "internal error: failed to instantiate observation manager";
@@ -799,43 +795,6 @@
     }
 
     /**
-     * Returns the event journal for this workspace. The events are filtered
-     * according to the passed criteria.
-     *
-     * @param eventTypes A combination of one or more event type constants encoded as a bitmask.
-     * @param absPath an absolute path.
-     * @param isDeep a <code>boolean</code>.
-     * @param uuid array of UUIDs.
-     * @param nodeTypeName array of node type names.
-     * @return the event journal for this repository.
-     * @throws UnsupportedRepositoryOperationException if this repository does
-     *          not support an event journal (cluster journal disabled).
-     * @throws RepositoryException if another error occurs.
-     */
-    public EventJournal getEventJournal(int eventTypes,
-                                        String absPath,
-                                        boolean isDeep,
-                                        String[] uuid,
-                                        String[] nodeTypeName)
-            throws RepositoryException {
-        Subject subject = ((SessionImpl) getSession()).getSubject();
-        if (subject.getPrincipals(AdminPrincipal.class).isEmpty()) {
-            throw new RepositoryException("Only administrator session may " +
-                    "access EventJournal");
-        }
-        ClusterNode clusterNode = rep.getClusterNode();
-        if (clusterNode == null) {
-            throw new UnsupportedRepositoryOperationException();
-        }
-
-        ObservationManagerImpl obsMgr = (ObservationManagerImpl) session.getWorkspace().getObservationManager();
-        EventFilter filter = obsMgr.createEventFilter(eventTypes, absPath,
-                isDeep, uuid, nodeTypeName, false);
-        return new EventJournalImpl(filter, clusterNode.getJournal(),
-                clusterNode.getId());
-    }
-
-    /**
      * {@inheritDoc}
      */
     public synchronized QueryManager getQueryManager() throws RepositoryException {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java?rev=770224&r1=770223&r2=770224&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
Thu Apr 30 13:49:17 2009
@@ -19,17 +19,22 @@
 import org.apache.jackrabbit.core.ItemManager;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.cluster.ClusterNode;
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
+import org.apache.jackrabbit.core.security.principal.AdminPrincipal;
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.Path;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.observation.EventJournal;
 import javax.jcr.observation.EventListener;
 import javax.jcr.observation.EventListenerIterator;
 import javax.jcr.observation.ObservationManager;
+import javax.security.auth.Subject;
 
 /**
  * Each <code>Session</code> instance has its own <code>ObservationManager</code>
@@ -55,6 +60,11 @@
     private final ItemManager itemMgr;
 
     /**
+     * The cluster node where this session is running.
+     */
+    private final ClusterNode clusterNode;
+
+    /**
      * The <code>ObservationDispatcher</code>
      */
     private final ObservationDispatcher dispatcher;
@@ -80,9 +90,9 @@
      * @throws NullPointerException if <code>session</code> or <code>itemMgr</code>
      *                              is <code>null</code>.
      */
-    public ObservationManagerImpl(ObservationDispatcher dispatcher,
-                           SessionImpl session,
-                           ItemManager itemMgr) throws NullPointerException {
+    public ObservationManagerImpl(
+            ObservationDispatcher dispatcher, SessionImpl session,
+            ItemManager itemMgr, ClusterNode clusterNode) {
         if (session == null) {
             throw new NullPointerException("session");
         }
@@ -93,6 +103,7 @@
         this.dispatcher = dispatcher;
         this.session = session;
         this.itemMgr = itemMgr;
+        this.clusterNode = clusterNode;
     }
 
     /**
@@ -220,6 +231,54 @@
                 isDeep, ids, nodeTypes, noLocal);
     }
 
+    /**
+     * Returns the event journal for this workspace. The events are filtered
+     * according to the passed criteria.
+     *
+     * @param eventTypes A combination of one or more event type constants encoded as a bitmask.
+     * @param absPath an absolute path.
+     * @param isDeep a <code>boolean</code>.
+     * @param uuid array of UUIDs.
+     * @param nodeTypeName array of node type names.
+     * @return the event journal for this repository.
+     * @throws UnsupportedRepositoryOperationException if this repository does
+     *          not support an event journal (cluster journal disabled).
+     * @throws RepositoryException if another error occurs.
+     */
+    public EventJournal getEventJournal(
+            int eventTypes, String absPath, boolean isDeep,
+            String[] uuid, String[] nodeTypeName)
+            throws RepositoryException {
+        if (clusterNode == null) {
+            throw new UnsupportedRepositoryOperationException(
+                    "Event journal is only available in cluster deployments");
+        }
+
+        Subject subject = session.getSubject();
+        if (subject.getPrincipals(AdminPrincipal.class).isEmpty()) {
+            throw new RepositoryException("Only administrator session may " +
+                    "access EventJournal");
+        }
+
+        ObservationManagerImpl obsMgr = (ObservationManagerImpl) session.getWorkspace().getObservationManager();
+        EventFilter filter = obsMgr.createEventFilter(eventTypes, absPath,
+                isDeep, uuid, nodeTypeName, false);
+        return new EventJournalImpl(filter, clusterNode.getJournal(),
+                clusterNode.getId());
+    }
+
+    /**
+     * Returns an unfiltered event journal for this workspace.
+     *
+     * @return the event journal for this repository.
+     * @throws UnsupportedRepositoryOperationException if this repository does
+     *          not support an event journal (cluster journal disabled).
+     * @throws RepositoryException if another error occurs.
+     */
+    public EventJournal getEventJournal() throws RepositoryException {
+        return getEventJournal(-1, "/", true, null, null);
+    }
+
     //------------------------------------------< EventStateCollectionFactory >
 
     /**
@@ -233,4 +292,5 @@
         esc.setUserData(userData);
         return esc;
     }
+
 }



Mime
View raw message