You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2009/09/08 18:09:45 UTC

svn commit: r812570 [6/24] - in /jackrabbit/sandbox/JCR-1456: ./ jackrabbit-api/ jackrabbit-api/src/main/appended-resources/ jackrabbit-api/src/main/appended-resources/META-INF/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/ jackrabbi...

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java Tue Sep  8 16:09:28 2009
@@ -22,6 +22,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
 
 import javax.jcr.RepositoryException;
 
@@ -40,9 +41,9 @@
 import org.apache.jackrabbit.core.journal.RecordProducer;
 import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
+import org.apache.jackrabbit.core.observation.EventState;
 import org.apache.jackrabbit.core.state.ChangeLog;
 import org.apache.jackrabbit.core.xml.ClonedInputSource;
-import org.apache.jackrabbit.uuid.UUID;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -138,7 +139,7 @@
      * @since Apache Jackrabbit 1.6
      * @see <a href="https://issues.apache.org/jira/browse/JCR-1753">JCR-1753</a>
      */
-    private volatile int syncCount = 0;
+    private volatile int syncCount;
 
     /**
      * Status flag, one of {@link #NONE}, {@link #STARTED} or {@link #STOPPED}.
@@ -148,12 +149,12 @@
     /**
      * Map of available lock listeners, indexed by workspace name.
      */
-    private final Map wspLockListeners = new HashMap();
+    private final Map<String, LockEventListener> wspLockListeners = new HashMap<String, LockEventListener>();
 
     /**
      * Map of available update listeners, indexed by workspace name.
      */
-    private final Map wspUpdateListeners = new HashMap();
+    private final Map<String, UpdateEventListener> wspUpdateListeners = new HashMap<String, UpdateEventListener>();
 
     /**
      * Versioning update listener.
@@ -169,7 +170,7 @@
      * Create workspace listener
      */
     private WorkspaceListener createWorkspaceListener;
-    
+
     /**
      * Node type listener.
      */
@@ -625,7 +626,7 @@
                 return;
             }
 
-            List events = update.getEvents();
+            List<EventState> events = update.getEvents();
             ChangeLog changes = update.getChanges();
             boolean succeeded = false;
 
@@ -840,7 +841,7 @@
 
         UpdateEventListener listener = null;
         if (workspace != null) {
-            listener = (UpdateEventListener) wspUpdateListeners.get(workspace);
+            listener = wspUpdateListeners.get(workspace);
             if (listener == null) {
                 try {
                     clusterContext.updateEventsReady(workspace);
@@ -849,7 +850,7 @@
                             workspace + " online: " + e.getMessage();
                     log.warn(msg);
                 }
-                listener = (UpdateEventListener) wspUpdateListeners.get(workspace);
+                listener = wspUpdateListeners.get(workspace);
                 if (listener ==  null) {
                     String msg = "Update listener unavailable for workspace: " + workspace;
                     log.error(msg);
@@ -883,7 +884,7 @@
     public void process(LockRecord record) {
         String workspace = record.getWorkspace();
 
-        LockEventListener listener = (LockEventListener) wspLockListeners.get(workspace);
+        LockEventListener listener = wspLockListeners.get(workspace);
         if (listener == null) {
             try {
                 clusterContext.lockEventsReady(workspace);
@@ -892,7 +893,7 @@
                         workspace + " online: " + e.getMessage();
                 log.warn(msg);
             }
-            listener = (LockEventListener) wspLockListeners.get(workspace);
+            listener = wspLockListeners.get(workspace);
             if (listener ==  null) {
                 String msg = "Lock channel unavailable for workspace: " + workspace;
                 log.error(msg);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterRecordProcessor.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterRecordProcessor.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterRecordProcessor.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterRecordProcessor.java Tue Sep  8 16:09:28 2009
@@ -30,33 +30,33 @@
      *
      * @param record change log record
      */
-    public void process(ChangeLogRecord record);
+    void process(ChangeLogRecord record);
 
     /**
      * Process a lock record.
      *
      * @param record lock record
      */
-    public void process(LockRecord record);
+    void process(LockRecord record);
 
     /**
      * Process a namespace record.
      *
      * @param record namespace record
      */
-    public void process(NamespaceRecord record);
+    void process(NamespaceRecord record);
 
     /**
      * Process a node type record
      *
      * @param record node type record
      */
-    public void process(NodeTypeRecord record);
+    void process(NodeTypeRecord record);
 
     /**
      * Process a workspace record
      * @param record workspace record
      */
-    public void process(WorkspaceRecord record);
+    void process(WorkspaceRecord record);
 
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterSession.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterSession.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterSession.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterSession.java Tue Sep  8 16:09:28 2009
@@ -56,6 +56,22 @@
     }
 
     /**
+     * Returns <code>true</code> if the given <code>userId</code> is the same as
+     * the {@link #userId} of this session.
+     *
+     * @param userId the user id or <code>null</code>.
+     * @return <code>true</code> if they are the same; <code>false</code>
+     *         otherwise.
+     */
+    boolean isUserId(String userId) {
+        if (userId == null) {
+            return this.userId == null;
+        } else {
+            return userId.equals(this.userId);
+        }
+    }
+
+    /**
      * {@inheritDoc}
      */
     public String getUserID() {
@@ -284,7 +300,7 @@
     public boolean equals(Object obj) {
         if (obj instanceof ClusterSession) {
             ClusterSession other = (ClusterSession) obj;
-            return userId.equals(other.userId);
+            return isUserId(other.userId);
         }
         return false;
     }
@@ -319,7 +335,7 @@
         throw new UnsupportedRepositoryOperationException();
     }
 
-    public boolean hasCapability(String arg0, Object arg1, Map arg2)
+    public boolean hasCapability(String arg0, Object arg1, Object[] arg2)
             throws RepositoryException {
         throw new UnsupportedRepositoryOperationException();
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeEventChannel.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeEventChannel.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeEventChannel.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeEventChannel.java Tue Sep  8 16:09:28 2009
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.core.cluster;
 
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
+import org.apache.jackrabbit.spi.Name;
 
 import java.util.Collection;
 
@@ -30,7 +31,7 @@
      *
      * @param ntDefs collection of node type definitions
      */
-    void registered(Collection ntDefs);
+    void registered(Collection<NodeTypeDef> ntDefs);
 
     /**
      * Called when a node types has been re-registered.
@@ -44,7 +45,7 @@
      *
      * @param ntNames collection of node type qnames
      */
-    void unregistered(Collection ntNames);
+    void unregistered(Collection<Name> ntNames);
 
     /**
      * Set listener that will receive information about incoming, external node type events.

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeEventListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeEventListener.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeEventListener.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/NodeTypeEventListener.java Tue Sep  8 16:09:28 2009
@@ -18,6 +18,7 @@
 
 import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
+import org.apache.jackrabbit.spi.Name;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
@@ -35,7 +36,7 @@
      * @throws RepositoryException if an error occurs
      * @throws InvalidNodeTypeDefException if the node type definition is invalid
      */
-    void externalRegistered(Collection ntDefs)
+    void externalRegistered(Collection<NodeTypeDef> ntDefs)
         throws RepositoryException, InvalidNodeTypeDefException;
 
     /**
@@ -56,7 +57,7 @@
      * @throws RepositoryException if an error occurs
      * @throws NoSuchNodeTypeException if a node type is already unregistered
      */
-    void externalUnregistered(Collection ntNames)
+    void externalUnregistered(Collection<Name> ntNames)
         throws RepositoryException, NoSuchNodeTypeException;
 
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/Update.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/Update.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/Update.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/Update.java Tue Sep  8 16:09:28 2009
@@ -18,6 +18,7 @@
 
 import java.util.List;
 
+import org.apache.jackrabbit.core.observation.EventState;
 import org.apache.jackrabbit.core.state.ChangeLog;
 
 /**
@@ -55,7 +56,7 @@
      *
      * @return collection of <code>EventState</code>s
      */
-    List getEvents();
+    List<EventState> getEvents();
 
     /**
      * Returns the timestamp whe this update occured.

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/WorkspaceListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/WorkspaceListener.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/WorkspaceListener.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/WorkspaceListener.java Tue Sep  8 16:09:28 2009
@@ -27,12 +27,12 @@
 
     /**
      * Workspace created on another cluster node.
-     * 
+     *
      * @param workspaceName
      * @param configTemplate
      * @throws RepositoryException
      */
-    public void externalWorkspaceCreated(String workspaceName,
+    void externalWorkspaceCreated(String workspaceName,
             InputSource configTemplate) throws RepositoryException;
 
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/WorkspaceRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/WorkspaceRecord.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/WorkspaceRecord.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/WorkspaceRecord.java Tue Sep  8 16:09:28 2009
@@ -44,7 +44,7 @@
     /**
      * Base workspace action
      */
-    public static abstract class Action {
+    public abstract static class Action {
         abstract int getType();
 
         abstract void write(Record record) throws JournalException;
@@ -57,8 +57,8 @@
      */
     static final class CreateWorkspaceAction extends Action {
         private InputSource inputSource;
-        private char charArray[];
-        private byte byteArray[];
+        private char[] charArray;
+        private byte[] byteArray;
 
         int getType() {
             return CREATE_WORKSPACE_ACTION_TYPE;
@@ -127,7 +127,7 @@
 
     /**
      * Creates a new {@link WorkspaceRecord} for create workspace action.
-     * 
+     *
      * @param workspace
      *            workspace name
      * @param inputSource
@@ -144,7 +144,7 @@
 
     /**
      * Creates a new empty {@link WorkspaceRecord}.
-     * 
+     *
      * @param record
      */
     protected WorkspaceRecord(Record record) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java Tue Sep  8 16:09:28 2009
@@ -22,6 +22,11 @@
 
 import java.util.Iterator;
 import java.util.Properties;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+import java.io.InputStream;
+import java.io.IOException;
 
 /**
  * Bean configuration class. BeanConfig instances contain the class name
@@ -32,6 +37,27 @@
 
     private static Logger log = LoggerFactory.getLogger(BeanConfig.class);
 
+    private static final Map<String, String> DEPRECATIONS;
+
+    static {
+        try {
+            Map<String, String> temp = new HashMap<String, String>();
+            Properties props = new Properties();
+            InputStream in = BeanConfig.class.getResourceAsStream("deprecated-classes.properties");
+            try {
+                props.load(in);
+            } finally {
+                in.close();
+            }
+            for (Map.Entry<Object, Object> entry : props.entrySet()) {
+                temp.put(entry.getKey().toString(), entry.getValue().toString());
+            }
+            DEPRECATIONS = Collections.unmodifiableMap(temp);
+        } catch (IOException e) {
+            throw new InternalError("failed to read deprecated classes");
+        }
+    }
+
     /** The default class loader used by all instances of this class */
     private static ClassLoader defaultClassLoader =
         BeanConfig.class.getClassLoader();
@@ -74,6 +100,11 @@
      * @param properties initial properties of the bean
      */
     public BeanConfig(String className, Properties properties) {
+        if (DEPRECATIONS.containsKey(className)) {
+            String replacement = DEPRECATIONS.get(className);
+            log.info("{} is deprecated. Please use {} instead", className, replacement);
+            className = replacement;
+        }
         this.className = className;
         this.properties = (Properties) properties.clone();
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ClusterConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ClusterConfig.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ClusterConfig.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ClusterConfig.java Tue Sep  8 16:09:28 2009
@@ -17,8 +17,8 @@
 package org.apache.jackrabbit.core.config;
 
 /**
- * Cluster configuration. This encapsulates the security related sub
- * configuration {@link JournalConfig}.
+ * Cluster configuration. This includes the journal configuration
+ * {@link JournalConfig}.
  */
 public class ClusterConfig {
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java Tue Sep  8 16:09:28 2009
@@ -83,6 +83,12 @@
      */
     private static final String WORKSPACE_ACCESS_ELEMENT = "WorkspaceAccessManager";
 
+    /**
+     * Name of the optional UserManagerConfig element that defines the
+     * configuration options for the user manager.
+     */
+    private static final String USER_MANAGER_ELEMENT = "UserManager";
+
     /** Name of the general workspace configuration element. */
     public static final String WORKSPACES_ELEMENT = "Workspaces";
 
@@ -333,7 +339,13 @@
             if (element != null) {
                 wac = parseBeanConfig(smElement, WORKSPACE_ACCESS_ELEMENT);
             }
-            return new SecurityManagerConfig(bc, wspAttr, wac);
+
+            BeanConfig umc = null;
+            element = getElement(smElement, USER_MANAGER_ELEMENT, false);
+            if (element != null) {
+                umc = parseBeanConfig(smElement, USER_MANAGER_ELEMENT);
+            }
+            return new SecurityManagerConfig(bc, wspAttr, wac, umc);
         } else {
             return null;
         }
@@ -663,7 +675,7 @@
      * method returns <code>null</code>.
      *
      * @param parent parent of the <code>Journal</code> element
-     * @return journal configuration, or <code>null</code>
+     * @return cluster configuration, or <code>null</code>
      * @throws ConfigurationException if the configuration is broken
      */
     protected ClusterConfig parseClusterConfig(Element parent)

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/SecurityManagerConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/SecurityManagerConfig.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/SecurityManagerConfig.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/SecurityManagerConfig.java Tue Sep  8 16:09:28 2009
@@ -28,19 +28,38 @@
 public class SecurityManagerConfig extends BeanConfig {
 
     private final String workspaceName;
-    private final BeanConfig workspaceAccessConfig; 
+    private final BeanConfig workspaceAccessConfig;
+    private final BeanConfig userManagerConfig;
 
     /**
      * Creates an security manager configuration object from the
      * given bean configuration.
      *
      * @param config bean configuration
+     * @param workspaceName the security workspace name
+     * @param workspaceAccessConfig the configuration for the workspace access.
      */
     public SecurityManagerConfig(BeanConfig config, String workspaceName,
                                  BeanConfig workspaceAccessConfig) {
+        this(config, workspaceName, workspaceAccessConfig, null);
+    }
+
+    /**
+     * Creates an security manager configuration object from the
+     * given bean configuration.
+     *
+     * @param config bean configuration
+     * @param workspaceName the security workspace name
+     * @param workspaceAccessConfig the configuration for the workspace access.
+     * @param userManagerConfig Configuration options for the user manager.
+     */
+    public SecurityManagerConfig(BeanConfig config, String workspaceName,
+                                 BeanConfig workspaceAccessConfig,
+                                 BeanConfig userManagerConfig) {
         super(config);
         this.workspaceName = workspaceName;
         this.workspaceAccessConfig = workspaceAccessConfig;
+        this.userManagerConfig = userManagerConfig;
     }
 
     /**
@@ -61,4 +80,13 @@
     public BeanConfig getWorkspaceAccessConfig() {
         return workspaceAccessConfig;
     }
+
+    /**
+     * @return the configuration for the user manager.
+     * May be <code>null</code> if the configuration entry is missing (i.e.
+     * the system default should be used).
+     */
+    public BeanConfig getUserManagerConfig() {
+        return userManagerConfig;
+    }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java Tue Sep  8 16:09:28 2009
@@ -29,12 +29,15 @@
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import javax.jcr.InvalidItemStateException;
 import javax.jcr.Item;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
@@ -69,6 +72,9 @@
  */
 public class GarbageCollector {
 
+    /** logger instance */
+    private static final Logger LOG = LoggerFactory.getLogger(GarbageCollector.class);
+
     private ScanEventListener callback;
 
     private int sleepBetweenNodes;
@@ -305,26 +311,38 @@
         if (callback != null) {
             callback.beforeScanning(n);
         }
-        for (PropertyIterator it = n.getProperties(); it.hasNext();) {
-            Property p = it.nextProperty();
-            if (p.getType() == PropertyType.BINARY) {
-                if (n.hasProperty("jcr:uuid")) {
-                    rememberNode(n.getProperty("jcr:uuid").getString());
-                } else {
-                    rememberNode(n.getPath());
-                }
-                if (p.getDefinition().isMultiple()) {
-                    p.getLengths();
-                } else {
-                    p.getLength();
+        try {
+            for (PropertyIterator it = n.getProperties(); it.hasNext();) {
+                Property p = it.nextProperty();
+                try {
+                    if (p.getType() == PropertyType.BINARY) {
+                        if (n.hasProperty("jcr:uuid")) {
+                            rememberNode(n.getProperty("jcr:uuid").getString());
+                        } else {
+                            rememberNode(n.getPath());
+                        }
+                        if (p.isMultiple()) {
+                            p.getLengths();
+                        } else {
+                            p.getLength();
+                        }
+                    }
+                } catch (InvalidItemStateException e) {
+                    LOG.debug("Property removed concurrently - ignoring", e);
                 }
             }
+        } catch (InvalidItemStateException e) {
+            LOG.debug("Node removed concurrently - ignoring", e);
         }
         if (callback != null) {
             callback.afterScanning(n);
         }
-        for (NodeIterator it = n.getNodes(); it.hasNext();) {
-            recurse(it.nextNode(), sleep);
+        try {
+            for (NodeIterator it = n.getNodes(); it.hasNext();) {
+                recurse(it.nextNode(), sleep);
+            }
+        } catch (InvalidItemStateException e) {
+            LOG.debug("Node removed concurrently - ignoring", e);
         }
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java Tue Sep  8 16:09:28 2009
@@ -27,7 +27,6 @@
 import org.apache.jackrabbit.core.util.db.DbUtility;
 import org.apache.jackrabbit.core.util.db.StreamWrapper;
 import org.apache.jackrabbit.util.Text;
-import org.apache.jackrabbit.uuid.UUID;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,6 +46,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.UUID;
 import java.util.WeakHashMap;
 
 import javax.jcr.RepositoryException;
@@ -68,6 +68,7 @@
  *     &lt;param name="{@link #setCopyWhenReading(boolean) copyWhenReading}" value="true"/>
  *     &lt;param name="{@link #setTablePrefix(String) tablePrefix}" value=""/>
  *     &lt;param name="{@link #setSchemaObjectPrefix(String) schemaObjectPrefix}" value=""/>
+ *     &lt;param name="{@link #setSchemaCheckEnabled(String) schemaCheckEnabled}" value="true"/>
  * &lt/DataStore>
  * </pre>
  * <p>
@@ -179,6 +180,11 @@
     protected String schemaObjectPrefix = "";
 
     /**
+     * Whether the schema check must be done during initialization.
+     */
+    private boolean schemaCheckEnabled = true;
+
+    /**
      * The logical name of the DataSource to use.
      */
     protected String dataSourceName;
@@ -550,8 +556,9 @@
 
             conHelper = createConnectionHelper(getDataSource());
 
-            createCheckSchemaOperation().run();
-
+            if (isSchemaCheckEnabled()) {
+                createCheckSchemaOperation().run();
+            }
         } catch (Exception e) {
             throw convert("Can not init data store, driver=" + driver + " url=" + url + " user=" + user + 
                     " schemaObjectPrefix=" + schemaObjectPrefix + " tableSQL=" + tableSQL + " createTableSQL=" + createTableSQL, e);
@@ -828,6 +835,20 @@
     }
 
     /**
+     * @return whether the schema check is enabled
+     */
+    public final boolean isSchemaCheckEnabled() {
+        return schemaCheckEnabled;
+    }
+
+    /**
+     * @param enabled set whether the schema check is enabled
+     */
+    public final void setSchemaCheckEnabled(boolean enabled) {
+        schemaCheckEnabled = enabled;
+    }
+
+    /**
      * {@inheritDoc}
      */
     public synchronized void close() throws DataStoreException {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/BasedFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/BasedFileSystem.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/BasedFileSystem.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/BasedFileSystem.java Tue Sep  8 16:09:28 2009
@@ -89,13 +89,6 @@
     /**
      * {@inheritDoc}
      */
-    public void copy(String srcPath, String destPath) throws FileSystemException {
-        fsBase.copy(buildBasePath(srcPath), buildBasePath(destPath));
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public void createFolder(String folderPath) throws FileSystemException {
         fsBase.createFolder(buildBasePath(folderPath));
     }
@@ -138,14 +131,6 @@
     /**
      * {@inheritDoc}
      */
-    public RandomAccessOutputStream getRandomAccessOutputStream(String filePath)
-            throws FileSystemException {
-        return fsBase.getRandomAccessOutputStream(buildBasePath(filePath));
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public boolean hasChildren(String path) throws FileSystemException {
         return fsBase.hasChildren(buildBasePath(path));
     }
@@ -181,13 +166,6 @@
     /**
      * {@inheritDoc}
      */
-    public void touch(String filePath) throws FileSystemException {
-        fsBase.touch(buildBasePath(filePath));
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public String[] list(String folderPath) throws FileSystemException {
         return fsBase.list(buildBasePath(folderPath));
     }
@@ -205,11 +183,4 @@
     public String[] listFolders(String folderPath) throws FileSystemException {
         return fsBase.listFolders(buildBasePath(folderPath));
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void move(String srcPath, String destPath) throws FileSystemException {
-        fsBase.move(buildBasePath(srcPath), buildBasePath(destPath));
-    }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystem.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystem.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystem.java Tue Sep  8 16:09:28 2009
@@ -77,23 +77,6 @@
     OutputStream getOutputStream(String filePath) throws FileSystemException;
 
     /**
-     * Returns an output stream for writing bytes to the file denoted by this path.
-     * The file will be created if it doesn't exist. The current position of the
-     * file pointer is set to <code>0</code>. See also
-     * {@link RandomAccessOutputStream#seek(long)};
-     *
-     * @param filePath the path of the file.
-     * @return an random access output stream for writing bytes to the file.
-     * @throws FileSystemException           if the file could not be created or
-     *                                       if the output stream cannot be obtained.
-     * @throws UnsupportedOperationException if the implementation does
-     *                                       not support file access through a
-     *                                      {@link RandomAccessOutputStream}.
-     */
-    RandomAccessOutputStream getRandomAccessOutputStream(String filePath)
-            throws FileSystemException, UnsupportedOperationException;
-
-    /**
      * Creates the folder named by this path, including any necessary but
      * nonexistent parent folders. Note that if this operation fails it
      * may have succeeded in creating some of the necessary parent folders.
@@ -166,14 +149,6 @@
     long lastModified(String path) throws FileSystemException;
 
     /**
-     * Set the modified time of an existing file to now.
-     *
-     * @param filePath the path of the file.
-     * @throws FileSystemException if the path does not denote an existing file.
-     */
-    void touch(String filePath) throws FileSystemException;
-
-    /**
      * Returns an array of strings naming the files and folders
      * in the folder denoted by this path.
      *
@@ -228,22 +203,4 @@
      */
     void deleteFolder(String folderPath) throws FileSystemException;
 
-    /**
-     * Moves a file or folder to a new location.
-     *
-     * @param srcPath  the path of the file or folder to be moved.
-     * @param destPath the destination path to which the file or folder is to be moved.
-     * @throws FileSystemException if the move fails
-     */
-    void move(String srcPath, String destPath) throws FileSystemException;
-
-    /**
-     * Copies a file or folder to a new location.
-     *
-     * @param srcPath  the path of the file or folder to be copied.
-     * @param destPath the destination path to which the file or folder is to be copied.
-     * @throws FileSystemException if the copy fails
-     */
-    void copy(String srcPath, String destPath) throws FileSystemException;
-
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystemResource.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystemResource.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystemResource.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystemResource.java Tue Sep  8 16:09:28 2009
@@ -175,14 +175,6 @@
     }
 
     /**
-     * @see FileSystem#getRandomAccessOutputStream
-     */
-    public RandomAccessOutputStream getRandomAccessOutputStream()
-            throws FileSystemException {
-        return fs.getRandomAccessOutputStream(path);
-    }
-
-    /**
      * @see FileSystem#lastModified
      */
     public long lastModified() throws FileSystemException {
@@ -196,20 +188,6 @@
         return fs.length(path);
     }
 
-    /**
-     * @see FileSystem#touch
-     */
-    public void touch() throws FileSystemException {
-        fs.touch(path);
-    }
-
-    /**
-     * @see FileSystem#move
-     */
-    public void move(String destPath) throws FileSystemException {
-        fs.move(path, destPath);
-    }
-
     //-------------------------------------------< java.lang.Object overrides >
     /**
      * Returns the path string of this resource. This is just the

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/RandomAccessOutputStream.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/RandomAccessOutputStream.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/RandomAccessOutputStream.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/RandomAccessOutputStream.java Tue Sep  8 16:09:28 2009
@@ -23,6 +23,8 @@
  * Extends the regular <code>java.io.OutputStream</code> with a random
  * access facility. Multiple <code>write()</code> operations can be
  * positioned off sequence with the {@link #seek} method.
+ *
+ * @deprecated this class should no longer be used
  */
 public abstract class RandomAccessOutputStream extends OutputStream {
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DB2FileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DB2FileSystem.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DB2FileSystem.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DB2FileSystem.java Tue Sep  8 16:09:28 2009
@@ -52,10 +52,6 @@
         // preset some attributes to reasonable defaults
         schema = "db2";
         driver = "com.ibm.db2.jcc.DB2Driver";
-        schemaObjectPrefix = "";
-        user = "";
-        password = "";
-        initialized = false;
     }
 
     //-----------------------------------------< DatabaseFileSystem overrides >

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java Tue Sep  8 16:09:28 2009
@@ -70,6 +70,11 @@
     // initial size of buffer used to serialize objects
     protected static final int INITIAL_BUFFER_SIZE = 8192;
 
+    /**
+     * Whether the schema check must be done during initialization.
+     */
+    private boolean schemaCheckEnabled = true;
+
     /** the {@link ConnectionHelper} set in the {@link #init()} method */
     protected ConnectionHelper conHelper;
 
@@ -120,6 +125,20 @@
         this.schema = schema;
     }
 
+    /**
+     * @return whether the schema check is enabled
+     */
+    public final boolean isSchemaCheckEnabled() {
+        return schemaCheckEnabled;
+    }
+
+    /**
+     * @param enabled set whether the schema check is enabled
+     */
+    public final void setSchemaCheckEnabled(boolean enabled) {
+        schemaCheckEnabled = enabled;
+    }
+
     //-------------------------------------------< java.lang.Object overrides >
     /**
      * {@inheritDoc}
@@ -174,7 +193,9 @@
             schemaObjectPrefix = conHelper.prepareDbIdentifier(schemaObjectPrefix);
 
             // check if schema objects exist and create them if necessary
-            createCheckSchemaOperation().run();
+            if (isSchemaCheckEnabled()) {
+                createCheckSchemaOperation().run();
+            }
 
             // build sql statements
             buildSQLStatements();
@@ -539,7 +560,7 @@
                     }
                     names.add(name);
                 }
-                return (String[]) names.toArray(new String[names.size()]);
+                return names.toArray(new String[names.size()]);
             } catch (SQLException e) {
                 String msg = "failed to list child entries of folder: " + folderPath;
                 log.error(msg, e);
@@ -573,7 +594,7 @@
                 while (rs.next()) {
                     names.add(rs.getString(1));
                 }
-                return (String[]) names.toArray(new String[names.size()]);
+                return names.toArray(new String[names.size()]);
             } catch (SQLException e) {
                 String msg = "failed to list file entries of folder: " + folderPath;
                 log.error(msg, e);
@@ -627,38 +648,6 @@
     /**
      * {@inheritDoc}
      */
-    public void touch(String filePath) throws FileSystemException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        FileSystemPathUtil.checkFormat(filePath);
-
-        String parentDir = FileSystemPathUtil.getParentDir(filePath);
-        String name = FileSystemPathUtil.getName(filePath);
-
-        int count = 0;
-        synchronized (updateLastModifiedSQL) {
-            try {
-                count = conHelper.update(updateLastModifiedSQL, new Object[]{
-                        new Long(System.currentTimeMillis()),
-                        parentDir,
-                        name});
-            } catch (SQLException e) {
-                String msg = "failed to touch file: " + filePath;
-                log.error(msg, e);
-                throw new FileSystemException(msg, e);
-            }
-        }
-
-        if (count == 0) {
-            throw new FileSystemException("no such file: " + filePath);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public InputStream getInputStream(String filePath) throws FileSystemException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
@@ -784,163 +773,6 @@
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public RandomAccessOutputStream getRandomAccessOutputStream(final String filePath)
-            throws FileSystemException, UnsupportedOperationException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        FileSystemPathUtil.checkFormat(filePath);
-
-        final String parentDir = FileSystemPathUtil.getParentDir(filePath);
-        final String name = FileSystemPathUtil.getName(filePath);
-
-        if (!isFolder(parentDir)) {
-            throw new FileSystemException("path not found: " + parentDir);
-        }
-
-        if (isFolder(filePath)) {
-            throw new FileSystemException("path denotes folder: " + filePath);
-        }
-
-        try {
-            TransientFileFactory fileFactory = TransientFileFactory.getInstance();
-            final File tmpFile = fileFactory.createTransientFile("bin", null, null);
-
-            // @todo FIXME use java.sql.Blob
-
-            if (isFile(filePath)) {
-                // file entry exists, spool contents to temp file first
-                InputStream in = getInputStream(filePath);
-                OutputStream out = new FileOutputStream(tmpFile);
-                try {
-                    IOUtils.copy(in, out);
-                } finally {
-                    out.close();
-                    in.close();
-                }
-            }
-
-            return new RandomAccessOutputStream() {
-                private final RandomAccessFile raf =
-                    new RandomAccessFile(tmpFile, "rw");
-
-                public void close() throws IOException {
-                    raf.close();
-
-                    InputStream in = null;
-                    try {
-                        if (isFile(filePath)) {
-                            synchronized (updateDataSQL) {
-                                long length = tmpFile.length();
-                                in = new FileInputStream(tmpFile);
-                                conHelper.exec(updateDataSQL,
-                                        new Object[]{
-                                            new StreamWrapper(in, length),
-                                            new Long(System.currentTimeMillis()),
-                                            new Long(length),
-                                            parentDir,
-                                            name
-                                        });
-                            }
-                        } else {
-                            synchronized (insertFileSQL) {
-                                long length = tmpFile.length();
-                                in = new FileInputStream(tmpFile);
-                                conHelper.exec(insertFileSQL,
-                                        new Object[]{
-                                            parentDir,
-                                            name,
-                                            new StreamWrapper(in, length),
-                                            new Long(System.currentTimeMillis()),
-                                            new Long(length)
-                                        });
-                            }
-                        }
-
-                    } catch (Exception e) {
-                        IOException ioe = new IOException(e.getMessage());
-                        ioe.initCause(e);
-                        throw ioe;
-                    } finally {
-                        if (in != null) {
-                            in.close();
-                        }
-                        // temp file can now safely be removed
-                        tmpFile.delete();
-                    }
-                }
-
-                public void seek(long position) throws IOException {
-                    raf.seek(position);
-                }
-
-                public void write(int b) throws IOException {
-                    raf.write(b);
-                }
-
-                public void flush() /*throws IOException*/ {
-                    // nop
-                }
-
-                public void write(byte[] b) throws IOException {
-                    raf.write(b);
-                }
-
-                public void write(byte[] b, int off, int len) throws IOException {
-                    raf.write(b, off, len);
-                }
-            };
-        } catch (Exception e) {
-            String msg = "failed to open output stream to file: " + filePath;
-            log.error(msg, e);
-            throw new FileSystemException(msg, e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void copy(String srcPath, String destPath) throws FileSystemException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        FileSystemPathUtil.checkFormat(srcPath);
-        FileSystemPathUtil.checkFormat(destPath);
-
-        if (isFolder(srcPath)) {
-            // src is a folder
-            copyDeepFolder(srcPath, destPath);
-        } else {
-            // src is a file
-            copyFile(srcPath, destPath);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void move(String srcPath, String destPath) throws FileSystemException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        FileSystemPathUtil.checkFormat(srcPath);
-        FileSystemPathUtil.checkFormat(destPath);
-
-        // @todo optimize move (use sql update stmts)
-        copy(srcPath, destPath);
-        if (isFile(srcPath)) {
-            deleteFile(srcPath);
-        } else {
-            deleteFolder(srcPath);
-        }
-    }
-
     //----------------------------------< misc. helper methods & overridables >
 
     /**
@@ -1102,86 +934,4 @@
         }
     }
 
-    /**
-     * Recursively copies the given folder to the given destination.
-     *
-     * @param srcPath folder to be copied
-     * @param destPath destination path to which the folder is to be copied
-     * @throws FileSystemException if an error occurs
-     */
-    protected void copyDeepFolder(String srcPath, String destPath)
-            throws FileSystemException {
-
-        if (!exists(destPath)) {
-            createDeepFolder(destPath);
-        }
-
-        String[] names = listFolders(srcPath);
-
-        for (int i = 0; i < names.length; i++) {
-            String src = (FileSystemPathUtil.denotesRoot(srcPath)
-                    ? srcPath + names[i] : srcPath + FileSystem.SEPARATOR + names[i]);
-            String dest = (FileSystemPathUtil.denotesRoot(destPath)
-                    ? destPath + names[i] : destPath + FileSystem.SEPARATOR + names[i]);
-            copyDeepFolder(src, dest);
-        }
-
-        synchronized (copyFilesSQL) {
-            try {
-                conHelper.exec(copyFilesSQL, new Object[]{destPath, srcPath});
-            } catch (SQLException e) {
-                String msg = "failed to copy file entries from " + srcPath + " to " + destPath;
-                log.error(msg, e);
-                throw new FileSystemException(msg, e);
-            }
-        }
-    }
-
-    /**
-     * Copies the given file entry to the given destination path. The parent
-     * folder of the destination path will be created if it doesn't exist
-     * already. If the destination path refers to an existing file, the file
-     * will be overwritten.
-     *
-     * @param srcPath file to be copied
-     * @param destPath destination path to which the file is to be copied
-     * @throws FileSystemException if an error occurs
-     */
-    protected void copyFile(String srcPath, String destPath)
-            throws FileSystemException {
-
-        final String srcParentDir = FileSystemPathUtil.getParentDir(srcPath);
-        final String srcName = FileSystemPathUtil.getName(srcPath);
-
-        final String destParentDir = FileSystemPathUtil.getParentDir(destPath);
-        final String destName = FileSystemPathUtil.getName(destPath);
-
-        if (!exists(destParentDir)) {
-            createDeepFolder(destParentDir);
-        }
-        if (isFile(destPath)) {
-            deleteFile(destPath);
-        }
-
-        int count = 0;
-        synchronized (copyFileSQL) {
-            try {
-                count = conHelper.update(
-                        copyFileSQL,
-                        new Object[]{
-                                destParentDir,
-                                destName,
-                                srcParentDir,
-                                srcName});
-            } catch (SQLException e) {
-                String msg = "failed to copy file from " + srcPath + " to " + destPath;
-                log.error(msg, e);
-                throw new FileSystemException(msg, e);
-            }
-        }
-
-        if (count == 0) {
-            throw new FileSystemException("no such file: " + srcPath);
-        }
-    }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/LocalFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/LocalFileSystem.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/LocalFileSystem.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/LocalFileSystem.java Tue Sep  8 16:09:28 2009
@@ -18,7 +18,6 @@
 
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
-import org.apache.jackrabbit.core.fs.RandomAccessOutputStream;
 import org.apache.jackrabbit.util.LazyFileInputStream;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -30,7 +29,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.RandomAccessFile;
 
 /**
  * A <code>LocalFileSystem</code> ...
@@ -179,23 +177,6 @@
     /**
      * {@inheritDoc}
      */
-    public void copy(String srcPath, String destPath)
-            throws FileSystemException {
-        File src = new File(root, osPath(srcPath));
-        File dest = new File(root, osPath(destPath));
-        try {
-            FileUtil.copy(src, dest);
-        } catch (IOException ioe) {
-            String msg = "copying " + src.getPath() + " to "
-                    + dest.getPath() + " failed";
-            log.debug(msg);
-            throw new FileSystemException(msg, ioe);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public void createFolder(String folderPath) throws FileSystemException {
         File f = new File(root, osPath(folderPath));
         if (f.exists()) {
@@ -296,21 +277,6 @@
     /**
      * {@inheritDoc}
      */
-    public RandomAccessOutputStream getRandomAccessOutputStream(String filePath)
-            throws FileSystemException {
-        File f = new File(root, osPath(filePath));
-        try {
-            return new RAFOutputStream(new RandomAccessFile(f, "rw"));
-        } catch (IOException e) {
-            String msg = "failed to get output stream for " + f.getPath();
-            log.debug(msg);
-            throw new FileSystemException(msg, e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public boolean hasChildren(String path) throws FileSystemException {
         File f = new File(root, osPath(path));
         if (!f.exists()) {
@@ -362,14 +328,6 @@
     /**
      * {@inheritDoc}
      */
-    public void touch(String filePath) throws FileSystemException {
-        File f = new File(root, osPath(filePath));
-        f.setLastModified(System.currentTimeMillis());
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public String[] list(String folderPath) throws FileSystemException {
         File f = new File(root, osPath(folderPath));
         String[] entries = f.list();
@@ -425,42 +383,4 @@
         return entries;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void move(String srcPath, String destPath)
-            throws FileSystemException {
-        File src = new File(root, osPath(srcPath));
-        File dest = new File(root, osPath(destPath));
-
-        if (dest.exists()) {
-            // we need to move the existing file/folder out of the way first
-            try {
-                FileUtil.delete(dest);
-            } catch (IOException ioe) {
-                String msg = "moving " + src.getPath() + " to "
-                        + dest.getPath() + " failed";
-                log.debug(msg);
-                throw new FileSystemException(msg, ioe);
-            }
-        }
-        File destParent = dest.getParentFile();
-        if (!destParent.exists()) {
-            // create destination parent folder first
-            if (!destParent.mkdirs()) {
-                String msg = "moving " + src.getPath() + " to "
-                        + dest.getPath() + " failed";
-                log.debug(msg);
-                throw new FileSystemException(msg);
-            }
-        }
-
-        // now we're ready to move/rename the file/folder
-        if (!src.renameTo(dest)) {
-            String msg = "moving " + src.getPath() + " to "
-                    + dest.getPath() + " failed";
-            log.debug(msg);
-            throw new FileSystemException(msg);
-        }
-    }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFile.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFile.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFile.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFile.java Tue Sep  8 16:09:28 2009
@@ -16,6 +16,9 @@
  */
 package org.apache.jackrabbit.core.fs.mem;
 
+/**
+ * An in-memory file.
+ */
 public class MemoryFile extends MemoryFileSystemEntry {
 
     private byte[] data = new byte[0];

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java Tue Sep  8 16:09:28 2009
@@ -24,36 +24,22 @@
 import java.io.OutputStream;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
-import org.apache.jackrabbit.core.fs.RandomAccessOutputStream;
 
+/**
+ * An in-memory file system implementation.
+ */
 public class MemoryFileSystem implements FileSystem {
 
-    private Map entries = new HashMap();
+    private Map<String, MemoryFileSystemEntry> entries = new HashMap<String, MemoryFileSystemEntry>();
 
     public void close() {
     }
 
-    public void copy(String srcPath, String destPath)
-            throws FileSystemException {
-        assertExistence(srcPath);
-        MemoryFile srcFile = getFile(srcPath);
-        OutputStream destinationOutputStream = getOutputStream(destPath);
-        try {
-            destinationOutputStream.write(srcFile.getData());
-        } catch (IOException e) {
-            throw new FileSystemException(e.getMessage(), e);
-        } finally {
-            IOUtils.closeQuietly(destinationOutputStream);
-        }
-    }
-
     private MemoryFile getFile(String filePath) throws FileSystemException {
         MemoryFileSystemEntry entry = getEntry(filePath);
         assertIsFile(filePath);
@@ -90,16 +76,13 @@
 
     public void deleteFolder(String folderPath) throws FileSystemException {
         assertIsFolder(folderPath);
-        Set allNames = entries.keySet();
-        Set selectedNames = new HashSet();
-        for (Iterator iter = allNames.iterator(); iter.hasNext();) {
-            String name = (String) iter.next();
-            if (name.startsWith(folderPath)) {
+        Set<String> selectedNames = new HashSet<String>();
+        for (String name : entries.keySet()) {
+            if (name.equals(folderPath) || name.startsWith(folderPath + SEPARATOR)) {
                 selectedNames.add(name);
             }
         }
-        for (Iterator iter = selectedNames.iterator(); iter.hasNext();) {
-            String name = (String) iter.next();
+        for (String name : selectedNames) {
             entries.remove(name);
         }
     }
@@ -159,12 +142,6 @@
         };
     }
 
-    public RandomAccessOutputStream getRandomAccessOutputStream(String filePath)
-            throws UnsupportedOperationException {
-        throw new UnsupportedOperationException(
-                "Random access is not implemented for the memory file system");
-    }
-
     public boolean hasChildren(String path) throws FileSystemException {
         assertIsFolder(path);
         return list(path).length > 0;
@@ -179,7 +156,7 @@
     }
 
     private MemoryFileSystemEntry getEntry(String path) {
-        return ((MemoryFileSystemEntry) entries.get(path));
+        return entries.get(path);
     }
 
     private void assertExistence(String path) throws FileSystemException {
@@ -210,15 +187,13 @@
         if (folderPath.equals("/")) {
             folderPath = "";
         }
-        Set allNames = entries.keySet();
-        Set selectedNames = new HashSet();
-        for (Iterator iter = allNames.iterator(); iter.hasNext();) {
-            String name = (String) iter.next();
+        Set<String> selectedNames = new HashSet<String>();
+        for (String name : entries.keySet()) {
             if (name.matches(folderPath + "/[^/]*") && !name.equals("/")) {
                 selectedNames.add(name.substring(folderPath.length() + 1));
             }
         }
-        return (String[]) selectedNames.toArray(new String[selectedNames.size()]);
+        return selectedNames.toArray(new String[selectedNames.size()]);
     }
 
     public String[] listFiles(String folderPath) {
@@ -234,57 +209,13 @@
         if (folderPath.equals("/")) {
             folderPath = "";
         }
-        Set result = new HashSet();
-        for (int i = 0; i < names.length; i++) {
-            if (getEntry(folderPath + "/" + names[i]).isFolder() == isFolder) {
-                result.add(names[i]);
-            }
-        }
-        return (String[]) result.toArray(new String[result.size()]);
-    }
-
-    public void move(String srcPath, String destPath)
-            throws FileSystemException {
-        assertExistence(srcPath);
-        if (exists(destPath)) {
-            throw new FileSystemException("Destination exists: " + destPath);
-        }
-
-        // Create destination folder if it does not yet exist
-        String[] path = destPath.split(SEPARATOR);
-        String folder = "";
-        for (int i = 1; i < path.length; i++) {
-            folder += SEPARATOR + path[i];
-            if (!exists(folder)) {
-                createFolder(folder);
-            }
-        }
-        
-        Map moves = new HashMap();
-        moves.put(srcPath, destPath);
-        if (getEntry(srcPath).isFolder()) {
-            srcPath = srcPath + "/";
-            Iterator iterator = entries.keySet().iterator();
-            while (iterator.hasNext()) {
-                String name = (String) iterator.next();
-                if (name.startsWith(srcPath)) {
-                    moves.put(
-                            name,
-                            destPath + "/" + name.substring(srcPath.length()));
-                }
+        Set<String> result = new HashSet<String>();
+        for (String n : names) {
+            if (getEntry(folderPath + "/" + n).isFolder() == isFolder) {
+                result.add(n);
             }
         }
-
-        Iterator iterator = moves.entrySet().iterator();
-        while (iterator.hasNext()) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            entries.put(entry.getValue(), entries.remove(entry.getKey()));
-        }
-    }
-
-    public void touch(String filePath) throws FileSystemException {
-        assertIsFile(filePath);
-        getEntry(filePath).touch();
+        return result.toArray(new String[result.size()]);
     }
 
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystemEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystemEntry.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystemEntry.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystemEntry.java Tue Sep  8 16:09:28 2009
@@ -16,6 +16,9 @@
  */
 package org.apache.jackrabbit.core.fs.mem;
 
+/**
+ * An in-memory file or folder.
+ */
 public abstract class MemoryFileSystemEntry {
 
     private long lastModified;
@@ -30,8 +33,4 @@
         return lastModified;
     }
 
-    public void touch() {
-        this.lastModified = System.currentTimeMillis();
-    }
-
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFolder.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFolder.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFolder.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFolder.java Tue Sep  8 16:09:28 2009
@@ -16,6 +16,9 @@
  */
 package org.apache.jackrabbit.core.fs.mem;
 
+/**
+ * An in-memory folder.
+ */
 public class MemoryFolder extends MemoryFileSystemEntry {
 
     public boolean isFolder() {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeId.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeId.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeId.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeId.java Tue Sep  8 16:09:28 2009
@@ -30,6 +30,11 @@
     private static final long serialVersionUID = 5773949574212570258L;
 
     /**
+     * Number of bytes in a UUID (16).
+     */
+    public static final int UUID_BYTE_LENGTH = 16;
+
+    /**
      * Returns a node identifier that is represented by the given UUID string.
      *
      * @param uuid the UUID string

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java Tue Sep  8 16:09:28 2009
@@ -178,20 +178,36 @@
         return repository.getDescriptorKeys();
     }
 
+    /**
+     * Delegated to the underlying repository instance.
+     * {@inheritDoc}
+     */
     public Value getDescriptorValue(String key) {
-        throw new RuntimeException("not implemented yet - see JCR-2062");
+        return repository.getDescriptorValue(key);
     }
 
+    /**
+     * Delegated to the underlying repository instance.
+     * {@inheritDoc}
+     */
     public Value[] getDescriptorValues(String key) {
-        throw new RuntimeException("not implemented yet - see JCR-2062");
+        return repository.getDescriptorValues(key);
     }
 
+    /**
+     * Delegated to the underlying repository instance.
+     * {@inheritDoc}
+     */
     public boolean isSingleValueDescriptor(String key) {
-        throw new RuntimeException("not implemented yet - see JCR-2062");
+        return repository.isSingleValueDescriptor(key);
     }
 
+    /**
+     * Delegated to the underlying repository instance.
+     * {@inheritDoc}
+     */
     public boolean isStandardDescriptor(String key) {
-        throw new RuntimeException("not implemented yet - see JCR-2062");
+        return repository.isStandardDescriptor(key);
     }
 
     //--------------------------------------------------------< Referenceable >

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractJournal.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractJournal.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractJournal.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractJournal.java Tue Sep  8 16:09:28 2009
@@ -16,19 +16,19 @@
  */
 package org.apache.jackrabbit.core.journal;
 
-import EDU.oswego.cs.dl.util.concurrent.ReadWriteLock;
-import EDU.oswego.cs.dl.util.concurrent.ReentrantWriterPreferenceReadWriteLock;
+import java.io.File;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.File;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
+import EDU.oswego.cs.dl.util.concurrent.ReadWriteLock;
+import EDU.oswego.cs.dl.util.concurrent.ReentrantWriterPreferenceReadWriteLock;
 
 /**
  * Base journal implementation.
@@ -58,12 +58,12 @@
     /**
      * Map of registered consumers.
      */
-    private final Map consumers = new HashMap();
+    private final Map<String, RecordConsumer> consumers = new HashMap<String, RecordConsumer>();
 
     /**
      * Map of registered producers.
      */
-    private final Map producers = new HashMap();
+    private final Map<String, RecordProducer> producers = new HashMap<String, RecordProducer>();
 
     /**
      * Journal lock, allowing multiple readers (synchronizing their contents)
@@ -128,7 +128,7 @@
      */
     public RecordConsumer getConsumer(String identifier) {
         synchronized (consumers) {
-            return (RecordConsumer) consumers.get(identifier);
+            return consumers.get(identifier);
         }
     }
 
@@ -137,7 +137,7 @@
      */
     public RecordProducer getProducer(String identifier) {
         synchronized (producers) {
-            RecordProducer producer = (RecordProducer) producers.get(identifier);
+            RecordProducer producer = producers.get(identifier);
             if (producer == null) {
                 producer = createProducer(identifier);
                 producers.put(identifier, producer);
@@ -163,9 +163,7 @@
         long minimalRevision = Long.MAX_VALUE;
 
         synchronized (consumers) {
-            Iterator iter = consumers.values().iterator();
-            while (iter.hasNext()) {
-                RecordConsumer consumer = (RecordConsumer) iter.next();
+            for (RecordConsumer consumer : consumers.values()) {
                 if (consumer.getRevision() < minimalRevision) {
                     minimalRevision = consumer.getRevision();
                 }
@@ -225,9 +223,7 @@
         }
 
         if (stopRevision > 0) {
-            Iterator iter = consumers.values().iterator();
-            while (iter.hasNext()) {
-                RecordConsumer consumer = (RecordConsumer) iter.next();
+            for (RecordConsumer consumer : consumers.values()) {
                 consumer.setRevision(stopRevision);
             }
             log.info("Synchronized to revision: " + stopRevision);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java Tue Sep  8 16:09:28 2009
@@ -40,8 +40,6 @@
 import org.apache.jackrabbit.spi.commons.nodetype.compact.CompactNodeTypeDefReader;
 import org.apache.jackrabbit.spi.commons.nodetype.compact.CompactNodeTypeDefWriter;
 import org.apache.jackrabbit.spi.commons.nodetype.compact.ParseException;
-import org.apache.jackrabbit.uuid.Constants;
-import org.apache.jackrabbit.uuid.UUID;
 
 /**
  * Base implementation for a record.
@@ -226,7 +224,7 @@
                 return (NodeId) nodeIdIndex.getKey(index);
             }
         } else if (uuidType == UUID_LITERAL) {
-            byte[] b = new byte[Constants.UUID_BYTE_LENGTH];
+            byte[] b = new byte[NodeId.UUID_BYTE_LENGTH];
             readFully(b);
             NodeId nodeId = new NodeId(b);
             nodeIdIndex.put(nodeId, nodeIdIndex.size());

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java Tue Sep  8 16:09:28 2009
@@ -65,6 +65,8 @@
  * which equals 24 hours)</li>
  * <li><code>janitorFirstRunHourOfDay</code>: specifies the hour at which the clean-up
  * thread initiates its first run (default = <code>3</code> which means 3:00 at night)</li>
+ * <li><code>schemaCheckEnabled</code>:  whether the schema check during initialization is enabled
+ * (default = <code>true</code>)</li>
  * <p>
  * JNDI can be used to get the connection. In this case, use the javax.naming.InitialContext as the driver,
  * and the JNDI name as the URL. If the user and password are configured in the JNDI resource,
@@ -162,6 +164,13 @@
         janitorNextRun.set(Calendar.MILLISECOND, 0);
     }
 
+    private Thread janitorThread;
+
+    /**
+     * Whether the schema check must be done during initialization.
+     */
+    private boolean schemaCheckEnabled = true;
+
     /**
      * The instance that manages the local revision.
      */
@@ -239,10 +248,14 @@
             schemaObjectPrefix = conHelper.prepareDbIdentifier(schemaObjectPrefix);
 
             // check if schema objects exist and create them if necessary
-            createCheckSchemaOperation().run();
+            if (isSchemaCheckEnabled()) {
+                createCheckSchemaOperation().run();
+            }
 
             // Make sure that the LOCAL_REVISIONS table exists (see JCR-1087)
-            checkLocalRevisionSchema();
+            if (isSchemaCheckEnabled()) {
+                checkLocalRevisionSchema();
+            }
 
             buildSQLStatements();
             initInstanceRevisionAndJanitor();
@@ -346,9 +359,9 @@
 
         // Start the clean-up thread if necessary.
         if (janitorEnabled) {
-            Thread t1 = new Thread(new RevisionTableJanitor(), "ClusterRevisionJanitor");
-            t1.setDaemon(true);
-            t1.start();
+            janitorThread = new Thread(new RevisionTableJanitor(), "Jackrabbit-ClusterRevisionJanitor");
+            janitorThread.setDaemon(true);
+            janitorThread.start();
             log.info("Cluster revision janitor thread started; first run scheduled at " + janitorNextRun.getTime());
         } else {
             log.info("Cluster revision janitor thread not started");
@@ -488,6 +501,9 @@
      * {@inheritDoc}
      */
     public void close() {
+        if (janitorThread != null) {
+            janitorThread.interrupt();
+        }
     }
 
     /**
@@ -680,6 +696,20 @@
     }
 
     /**
+     * @return whether the schema check is enabled
+     */
+    public final boolean isSchemaCheckEnabled() {
+        return schemaCheckEnabled;
+    }
+
+    /**
+     * @param enabled set whether the schema check is enabled
+     */
+    public final void setSchemaCheckEnabled(boolean enabled) {
+        schemaCheckEnabled = enabled;
+    }
+
+    /**
      * This class manages the local revision of the cluster node. It
      * persists the local revision in the LOCAL_REVISIONS table in the
      * clustering database.

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/InstanceRevision.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/InstanceRevision.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/InstanceRevision.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/InstanceRevision.java Tue Sep  8 16:09:28 2009
@@ -17,7 +17,7 @@
 package org.apache.jackrabbit.core.journal;
 
 /**
- * 
+ *
  */
 public interface InstanceRevision {
 
@@ -27,7 +27,7 @@
      * @return instance revision
      * @throws JournalException if some error occurs
      */
-    public long get() throws JournalException;
+    long get() throws JournalException;
 
     /**
      * Set current instance revision.
@@ -35,10 +35,10 @@
      * @param value new instance revision
      * @throws JournalException if some error occurs
      */
-    public void set(long value) throws JournalException;
-    
+    void set(long value) throws JournalException;
+
     /**
      * Closes the instance revision.
      */
-    public void close();
+    void close();
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Journal.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Journal.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Journal.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Journal.java Tue Sep  8 16:09:28 2009
@@ -79,7 +79,7 @@
      * @return the InstanceRevision manager
      * @throws JournalException on error
      */
-    public InstanceRevision getInstanceRevision() throws JournalException;
+    InstanceRevision getInstanceRevision() throws JournalException;
 
     /**
      * Return an iterator over all records after the specified revision.
@@ -88,7 +88,7 @@
      * @return an iterator over all records after the specified revision.
      * @throws JournalException if an error occurs
      */
-    public RecordIterator getRecords(long startRevision)
+    RecordIterator getRecords(long startRevision)
             throws JournalException;
 
     /**
@@ -97,5 +97,5 @@
      * @return an iterator over all records.
      * @throws JournalException if an error occurs
      */
-    public RecordIterator getRecords() throws JournalException;
+    RecordIterator getRecords() throws JournalException;
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/RotatingLogFile.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/RotatingLogFile.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/RotatingLogFile.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/RotatingLogFile.java Tue Sep  8 16:09:28 2009
@@ -28,7 +28,7 @@
 /**
  * Represents a log file that can be rotated.
  */
-public class RotatingLogFile implements Comparable {
+public class RotatingLogFile implements Comparable<RotatingLogFile> {
 
     /**
      * Logger.
@@ -129,13 +129,6 @@
     }
 
     /**
-     * {@inheritDoc}
-     */
-    public int compareTo(Object o) {
-        return compareTo((RotatingLogFile) o);
-    }
-
-    /**
      * Compares this log file to another file. It will return
      * a negative number if this log file has a smaller version,
      * a positive number if this log file a bigger version
@@ -161,7 +154,7 @@
             }
         });
 
-        ArrayList l = new ArrayList();
+        ArrayList<RotatingLogFile> l = new ArrayList<RotatingLogFile>();
         for (int i = 0; i < files.length; i++) {
             File file = files[i];
             try {
@@ -174,11 +167,9 @@
         RotatingLogFile[] logFiles = new RotatingLogFile[l.size()];
         l.toArray(logFiles);
 
-        Arrays.sort(logFiles, new Comparator() {
-            public int compare(Object o1, Object o2) {
-                RotatingLogFile lf1 = (RotatingLogFile) o1;
-                RotatingLogFile lf2 = (RotatingLogFile) o2;
-                return lf2.compareTo(lf1);
+        Arrays.sort(logFiles, new Comparator<RotatingLogFile>() {
+            public int compare(RotatingLogFile o1, RotatingLogFile o2) {
+                return o2.compareTo(o1);
             }
         });
         return logFiles;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockImpl.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockImpl.java Tue Sep  8 16:09:28 2009
@@ -38,7 +38,7 @@
     /**
      * Node holding lock
      */
-    protected final Node node;
+    protected final NodeImpl node;
 
     /**
      * Create a new instance of this class.
@@ -46,7 +46,7 @@
      * @param info lock information
      * @param node node holding lock
      */
-    public LockImpl(LockInfo info, Node node) {
+    public LockImpl(LockInfo info, NodeImpl node) {
         this.info = info;
         this.node = node;
     }
@@ -78,12 +78,9 @@
      * {@inheritDoc}
      */
     public String getLockToken() {
-        if (info.isSessionScoped()) {
-            return null;
-        }
-        try {
-            return info.getLockToken(node.getSession());
-        } catch (RepositoryException e) {
+        if (!info.isSessionScoped() && info.isLockHolder(node.getSession())) {
+            return info.getLockToken();
+        } else {
             return null;
         }
     }
@@ -109,38 +106,48 @@
      */
     public void refresh() throws LockException, RepositoryException {
         if (!isLive()) {
-            throw new LockException("Lock is not live any more.");
-        }
-        if (!isLockOwningSession()) {
-            throw new LockException("Session does not hold lock.");
+            info.throwLockException(
+                    "Lock is not live any more",
+                    (SessionImpl) node.getSession());
+        } else if (!isLockOwningSession()) {
+            info.throwLockException(
+                    "Session does not hold lock.",
+                    (SessionImpl) node.getSession());
+        } else {
+            // make sure the current session has sufficient privileges to refresh
+            // the lock.
+            SessionImpl session = (SessionImpl) node.getSession();
+            session.getAccessManager().checkPermission(
+                    node.getPrimaryPath(), Permission.LOCK_MNGMT);
+
+            // Update the lock timeout
+            info.updateTimeoutTime();
         }
-        // make sure the current session has sufficient privileges to refresh
-        // the lock.
-        SessionImpl s = (SessionImpl) node.getSession();
-        s.getAccessManager().checkPermission(((NodeImpl) node).getPrimaryPath(), Permission.LOCK_MNGMT);
-
-        // TODO: TOBEFIXED for 2.0
-        // TODO  - add refresh if timeout is supported -> see #getSecondsRemaining
-        // since a lock has no expiration date no other action is required
     }
 
     //--------------------------------------------------< new JSR 283 methods >
 
-    /**
-     * @see javax.jcr.lock.Lock#getSecondsRemaining()
-     */
+    /** {@inheritDoc} */
     public long getSecondsRemaining() {
-        return info.getSecondsRemaining();
+        if (!info.isLive()) {
+            return -1;
+        }
+
+        // TODO JCR-1590: Disabled until locks get unlocked when they timeout
+        long timeout = info.getTimeoutTime();
+        if (timeout == Long.MAX_VALUE) {
+            return Long.MAX_VALUE;
+        }
+
+        long now = (System.currentTimeMillis() + 999) / 1000; // round up
+        return Math.max(timeout - now, 1); // must always be positive
     }
 
     /**
      * @see javax.jcr.lock.Lock#isLockOwningSession()
      */
     public boolean isLockOwningSession() {
-        try {
-            return info.isLockHolder(node.getSession());
-        } catch (RepositoryException e) {
-            return false;
-        }
+        return info.isLockHolder(node.getSession());
     }
+
 }