jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1325199 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: ItemImpl.java ItemStateProvider.java NodeImpl.java PropertyImpl.java SessionImpl.java WorkspaceImpl.java query/QueryManagerImpl.java
Date Thu, 12 Apr 2012 10:43:18 GMT
Author: mduerig
Date: Thu Apr 12 10:43:17 2012
New Revision: 1325199

URL: http://svn.apache.org/viewvc?rev=1325199&view=rev
Log:
OAK-15: Clean up oak-jcr
- make ItemStateProvide package private
- synchronize state resolution
- better names for assertion

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemStateProvider.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java?rev=1325199&r1=1325198&r2=1325199&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
Thu Apr 12 10:43:17 2012
@@ -106,19 +106,20 @@ abstract class ItemImpl implements Item 
      */
     void checkStatus() throws RepositoryException {
         // check session status
-        sessionContext.getSession().checkIsAlive();
+        sessionContext.getSession().ensureIsAlive();
 
         // TODO: validate item state.
     }
 
     /**
-     * Checks if the associated session has pending changes.
+     * Ensure that the associated session has no pending changes and throw an
+     * exception otherwise.
      *
      * @throws InvalidItemStateException if this nodes session has pending changes
      * @throws RepositoryException
      */
-    void checkSessionHasPendingChanges() throws RepositoryException {
-        sessionContext.getSession().checkHasPendingChanges();
+    void ensureNoPendingSessionChanges() throws RepositoryException {
+        sessionContext.getSession().ensureNoPendingChanges();
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemStateProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemStateProvider.java?rev=1325199&r1=1325198&r2=1325199&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemStateProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemStateProvider.java
Thu Apr 12 10:43:17 2012
@@ -3,7 +3,7 @@ package org.apache.jackrabbit.oak.jcr;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.TransientNodeState;
 
-public class ItemStateProvider {
+class ItemStateProvider {
     private final TransientNodeState root;
 
     ItemStateProvider(TransientNodeState root) {

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1325199&r1=1325198&r2=1325199&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Thu Apr 12 10:43:17 2012
@@ -634,7 +634,7 @@ public class NodeImpl extends ItemImpl i
     @Override
     public void update(String srcWorkspace) throws RepositoryException {
         checkStatus();
-        checkSessionHasPendingChanges();
+        ensureNoPendingSessionChanges();
 
         // TODO
     }
@@ -842,7 +842,7 @@ public class NodeImpl extends ItemImpl i
         return sessionContext.getItemStateProvider();
     }
     
-    private TransientNodeState getNodeState() {
+    private synchronized TransientNodeState getNodeState() {
         return nodeState = getItemStateProvider().getNodeState(nodeState.getPath());
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java?rev=1325199&r1=1325198&r2=1325199&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
Thu Apr 12 10:43:17 2012
@@ -628,7 +628,7 @@ public class PropertyImpl extends ItemIm
         return getPropertyState().getName();
     }
 
-    private void resolve() {
+    private synchronized void resolve() {
         parentState = getItemStateProvider().getNodeState(parentState.getPath());
         propertyState = getItemStateProvider().getPropertyState(
                 Paths.concat(parentState.getPath(), propertyState.getName()));

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java?rev=1325199&r1=1325198&r2=1325199&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
Thu Apr 12 10:43:17 2012
@@ -101,7 +101,7 @@ public class SessionImpl extends Abstrac
      */
     @Override
     public Session impersonate(Credentials credentials) throws RepositoryException {
-        checkIsAlive();
+        ensureIsAlive();
 
         // TODO
         return null;
@@ -109,7 +109,7 @@ public class SessionImpl extends Abstrac
 
     @Override
     public ValueFactory getValueFactory() throws RepositoryException {
-        checkIsAlive();
+        ensureIsAlive();
         return sessionContext.getValueFactory();
     }
 
@@ -117,13 +117,13 @@ public class SessionImpl extends Abstrac
 
     @Override
     public Node getRootNode() throws RepositoryException {
-        checkIsAlive();
+        ensureIsAlive();
         return new NodeImpl(sessionContext, itemStateProvider.getNodeState("/"));
     }
 
     @Override
     public Node getNodeByUUID(String uuid) throws RepositoryException {
-        checkIsAlive();
+        ensureIsAlive();
 
         // TODO
         return null;
@@ -131,7 +131,7 @@ public class SessionImpl extends Abstrac
 
     @Override
     public Node getNodeByIdentifier(String id) throws RepositoryException {
-        checkIsAlive();
+        ensureIsAlive();
 
         // TODO
         return null;
@@ -141,7 +141,7 @@ public class SessionImpl extends Abstrac
 
     @Override
     public void move(String srcAbsPath, String destAbsPath) throws RepositoryException {
-        checkIsAlive();
+        ensureIsAlive();
 
         String srcPath = Paths.relativize("/", srcAbsPath);
         String destPath = Paths.relativize("/", destAbsPath);
@@ -152,7 +152,7 @@ public class SessionImpl extends Abstrac
 
     @Override
     public void save() throws RepositoryException {
-        checkIsAlive();
+        ensureIsAlive();
         try {
             connection.commit(editor);
             connection.refresh();
@@ -165,7 +165,7 @@ public class SessionImpl extends Abstrac
 
     @Override
     public void refresh(boolean keepChanges) throws RepositoryException {
-        checkIsAlive();
+        ensureIsAlive();
         connection.refresh();
         if (!keepChanges) {
             editor = connection.getNodeStateEditor(connection.getCurrentRoot());
@@ -175,7 +175,7 @@ public class SessionImpl extends Abstrac
 
     @Override
     public boolean hasPendingChanges() throws RepositoryException {
-        checkIsAlive();
+        ensureIsAlive();
 
         // todo implement hasPendingChanges
         return false;
@@ -210,7 +210,7 @@ public class SessionImpl extends Abstrac
 
     @Override
     public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior)
throws RepositoryException {
-        checkIsAlive();
+        ensureIsAlive();
 
         // TODO
         return null;
@@ -258,7 +258,7 @@ public class SessionImpl extends Abstrac
 
     @Override
     public boolean hasPermission(String absPath, String actions) throws RepositoryException
{
-        checkIsAlive();
+        ensureIsAlive();
 
         // TODO
         return false;
@@ -276,7 +276,7 @@ public class SessionImpl extends Abstrac
 
     @Override
     public boolean hasCapability(String methodName, Object target, Object[] arguments) throws
RepositoryException {
-        checkIsAlive();
+        ensureIsAlive();
 
         // TODO
         return false;
@@ -284,7 +284,7 @@ public class SessionImpl extends Abstrac
 
     @Override
     public AccessControlManager getAccessControlManager() throws RepositoryException {
-        checkIsAlive();
+        ensureIsAlive();
 
         // TODO
         return null;
@@ -300,12 +300,12 @@ public class SessionImpl extends Abstrac
     //--------------------------------------------------------------------------
 
     /**
-     * Performs a sanity check on this session.
+     * Ensure that this session is alive and throw an exception otherwise.
      *
      * @throws RepositoryException if this session has been rendered invalid
      * for some reason (e.g. if this session has been closed explicitly by logout)
      */
-    void checkIsAlive() throws RepositoryException {
+    void ensureIsAlive() throws RepositoryException {
         // check session status
         if (!isAlive) {
             throw new RepositoryException("This session has been closed.");
@@ -354,7 +354,8 @@ public class SessionImpl extends Abstrac
     }
 
     /**
-     * Make sure the repository supports the option indicated by the given string.
+     * Make sure the repository supports the option indicated by the given string
+     * and throw an exception otherwise.
      *
      * @param option Any of the option constants defined by {@link Repository}
      * that either returns 'true' or 'false'. I.e.
@@ -389,19 +390,20 @@ public class SessionImpl extends Abstrac
      * @throws RepositoryException If another error occurs.
      * @see javax.jcr.Repository#getDescriptorKeys()
      */
-    void checkSupportedOption(String option) throws RepositoryException {
+    void ensureSupportsOption(String option) throws RepositoryException {
         if (!isSupportedOption(option)) {
             throw new UnsupportedRepositoryOperationException(option + " is not supported
by this repository.");
         }
     }
 
     /**
-     * Checks if this session has pending changes.
+     * Ensure that this session has no pending changes and throw an exception
+     * otherwise.
      *
      * @throws InvalidItemStateException if this nodes session has pending changes
      * @throws RepositoryException
      */
-    void checkHasPendingChanges() throws RepositoryException {
+    void ensureNoPendingChanges() throws RepositoryException {
         // check for pending changes
         if (hasPendingChanges()) {
             String msg = "Unable to perform operation. Session has pending changes.";

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java?rev=1325199&r1=1325198&r2=1325199&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
Thu Apr 12 10:43:17 2012
@@ -74,8 +74,8 @@ public class WorkspaceImpl implements Wo
     @SuppressWarnings("deprecation")
     @Override
     public void copy(String srcWorkspace, String srcAbsPath, String destAbsPath) throws RepositoryException
{
-        getSessionImpl().checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
-        getSessionImpl().checkIsAlive();
+        ensureSupportedOption(Repository.LEVEL_2_SUPPORTED);
+        ensureIsAlive();
 
         try {
             Connection connection = sessionContext.getConnection();
@@ -95,8 +95,8 @@ public class WorkspaceImpl implements Wo
     @SuppressWarnings("deprecation")
     @Override
     public void clone(String srcWorkspace, String srcAbsPath, String destAbsPath, boolean
removeExisting) throws RepositoryException {
-        getSessionImpl().checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
-        getSessionImpl().checkIsAlive();
+        ensureSupportedOption(Repository.LEVEL_2_SUPPORTED);
+        ensureIsAlive();
 
         // TODO -> SPI
 
@@ -105,8 +105,8 @@ public class WorkspaceImpl implements Wo
     @SuppressWarnings("deprecation")
     @Override
     public void move(String srcAbsPath, String destAbsPath) throws RepositoryException {
-        getSessionImpl().checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
-        getSessionImpl().checkIsAlive();
+        ensureSupportedOption(Repository.LEVEL_2_SUPPORTED);
+        ensureIsAlive();
 
         try {
             Connection connection = sessionContext.getConnection();
@@ -130,8 +130,8 @@ public class WorkspaceImpl implements Wo
 
     @Override
     public LockManager getLockManager() throws RepositoryException {
-        getSessionImpl().checkIsAlive();
-        getSessionImpl().checkSupportedOption(Repository.OPTION_LOCKING_SUPPORTED);
+        ensureIsAlive();
+        ensureSupportedOption(Repository.OPTION_LOCKING_SUPPORTED);
 
         // TODO
         return null;
@@ -139,7 +139,7 @@ public class WorkspaceImpl implements Wo
 
     @Override
     public QueryManager getQueryManager() throws RepositoryException {
-        getSessionImpl().checkIsAlive();
+        ensureIsAlive();
         if (queryManager == null) {
             queryManager = new QueryManagerImpl(this, sessionContext);
         }
@@ -148,7 +148,7 @@ public class WorkspaceImpl implements Wo
 
     @Override
     public NamespaceRegistry getNamespaceRegistry() throws RepositoryException {
-        getSessionImpl().checkIsAlive();
+        ensureIsAlive();
 
         // TODO
         return null;
@@ -156,7 +156,7 @@ public class WorkspaceImpl implements Wo
 
     @Override
     public NodeTypeManager getNodeTypeManager() throws RepositoryException {
-        getSessionImpl().checkIsAlive();
+        ensureIsAlive();
 
         // TODO
         return null;
@@ -164,8 +164,8 @@ public class WorkspaceImpl implements Wo
 
     @Override
     public ObservationManager getObservationManager() throws RepositoryException {
-        getSessionImpl().checkSupportedOption(Repository.OPTION_OBSERVATION_SUPPORTED);
-        getSessionImpl().checkIsAlive();
+        ensureSupportedOption(Repository.OPTION_OBSERVATION_SUPPORTED);
+        ensureIsAlive();
 
         // TODO
         return null;
@@ -173,8 +173,8 @@ public class WorkspaceImpl implements Wo
 
     @Override
     public VersionManager getVersionManager() throws RepositoryException {
-        getSessionImpl().checkIsAlive();
-        getSessionImpl().checkSupportedOption(Repository.OPTION_VERSIONING_SUPPORTED);
+        ensureIsAlive();
+        ensureSupportedOption(Repository.OPTION_VERSIONING_SUPPORTED);
 
         // TODO
         return null;
@@ -182,7 +182,7 @@ public class WorkspaceImpl implements Wo
 
     @Override
     public String[] getAccessibleWorkspaceNames() throws RepositoryException {
-        getSessionImpl().checkIsAlive();
+        ensureIsAlive();
 
         // TODO -> SPI
         return null;
@@ -191,8 +191,8 @@ public class WorkspaceImpl implements Wo
     @SuppressWarnings("deprecation")
     @Override
     public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior)
throws RepositoryException {
-        getSessionImpl().checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
-        getSessionImpl().checkIsAlive();
+        ensureSupportedOption(Repository.LEVEL_2_SUPPORTED);
+        ensureIsAlive();
 
         // TODO
         return null;
@@ -201,38 +201,44 @@ public class WorkspaceImpl implements Wo
     @SuppressWarnings("deprecation")
     @Override
     public void importXML(String parentAbsPath, InputStream in, int uuidBehavior) throws
IOException, RepositoryException {
-        getSessionImpl().checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
-        getSessionImpl().checkIsAlive();
+        ensureSupportedOption(Repository.LEVEL_2_SUPPORTED);
+        ensureIsAlive();
 
         // TODO -> SPI
     }
 
     @Override
     public void createWorkspace(String name) throws RepositoryException {
-        getSessionImpl().checkIsAlive();
-        getSessionImpl().checkSupportedOption(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED);
+        ensureIsAlive();
+        ensureSupportedOption(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED);
 
         // TODO -> SPI
     }
 
     @Override
     public void createWorkspace(String name, String srcWorkspace) throws RepositoryException
{
-        getSessionImpl().checkIsAlive();
-        getSessionImpl().checkSupportedOption(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED);
+        ensureIsAlive();
+        ensureSupportedOption(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED);
 
         // TODO -> SPI
     }
 
     @Override
     public void deleteWorkspace(String name) throws RepositoryException {
-        getSessionImpl().checkIsAlive();
-        getSessionImpl().checkSupportedOption(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED);
+        ensureIsAlive();
+        ensureSupportedOption(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED);
 
         // TODO -> SPI
     }
 
     //------------------------------------------------------------< private >---
-    private SessionImpl getSessionImpl() {
-        return sessionContext.getSession();
+
+    private void ensureIsAlive() throws RepositoryException {
+        sessionContext.getSession().ensureIsAlive();
+    }
+
+    private void ensureSupportedOption(String option) throws RepositoryException {
+        sessionContext.getSession().ensureSupportsOption(option);
     }
+
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java?rev=1325199&r1=1325198&r2=1325199&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java
Thu Apr 12 10:43:17 2012
@@ -101,7 +101,7 @@ public class QueryManagerImpl implements
 
     private static HashMap<String, CoreValue> convertMap(HashMap<String, Value>
bindVariableMap)
             throws RepositoryException {
-        
+
         HashMap<String, CoreValue> map = new HashMap<String, CoreValue>();
         for (Entry<String, Value> e : bindVariableMap.entrySet()) {
             map.put(e.getKey(), ValueConverter.convert(e.getValue()));



Mime
View raw message