jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1196770 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cache/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/ jackrabbit-core/src...
Date Wed, 02 Nov 2011 19:21:36 GMT
Author: jukka
Date: Wed Nov  2 19:21:34 2011
New Revision: 1196770

URL: http://svn.apache.org/viewvc?rev=1196770&view=rev
Log:
JCR-97: Improve Checkstyle conformance

Fix various issues like empty if statements, missing braces, dead code, etc.

Avoid a ClassCastException from ConcurrentCache.values()

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cache/ConcurrentCache.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XAEnvironment.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleDumper.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CaseTermQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/MLRUItemStateCache.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplMerge.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/AccessControlImporter.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/BTreeManager.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/Rank.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/sql2/Parser.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/QueryObjectModelFactoryTest.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathParser.java
    jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/JcrClient.java
    jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/JcrParser.java
    jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/fs/ImportFileSystem.java
    jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/info/AbstractLsNodes.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java Wed Nov  2 19:21:34 2011
@@ -1243,24 +1243,25 @@ public class SessionImpl extends Abstrac
                     return false;
                 }
             }
-        } else if (target instanceof Workspace) {
-            if (methodName.equals("clone")
-                    || methodName.equals("copy")
-                    || methodName.equals("createWorkspace")
-                    || methodName.equals("deleteWorkspace")
-                    || methodName.equals("getImportContentHandler")
-                    || methodName.equals("importXML")
-                    || methodName.equals("move")) {
-                // todo minimal, best effort checks (e.g. permissions for write methods etc)
-            }
-        } else if (target instanceof Session) {
-            if (methodName.equals("clone")
-                    || methodName.equals("removeItem")
-                    || methodName.equals("getImportContentHandler")
-                    || methodName.equals("importXML")
-                    || methodName.equals("save")) {
-                // todo minimal, best effort checks (e.g. permissions for write methods etc)
-            }
+// TODO: Add minimal, best effort checks for Workspace and Session operations
+//        } else if (target instanceof Workspace) {
+//            if (methodName.equals("clone")
+//                    || methodName.equals("copy")
+//                    || methodName.equals("createWorkspace")
+//                    || methodName.equals("deleteWorkspace")
+//                    || methodName.equals("getImportContentHandler")
+//                    || methodName.equals("importXML")
+//                    || methodName.equals("move")) {
+//                // TODO minimal, best effort checks (e.g. permissions for write methods etc)
+//            }
+//        } else if (target instanceof Session) {
+//            if (methodName.equals("clone")
+//                    || methodName.equals("removeItem")
+//                    || methodName.equals("getImportContentHandler")
+//                    || methodName.equals("importXML")
+//                    || methodName.equals("save")) {
+//                // TODO minimal, best effort checks (e.g. permissions for write methods etc)
+//            }
         }
 
         // we're unable to evaluate capability, return true (staying on the safe side)

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cache/ConcurrentCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cache/ConcurrentCache.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cache/ConcurrentCache.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cache/ConcurrentCache.java Wed Nov  2 19:21:34 2011
@@ -140,8 +140,7 @@ public class ConcurrentCache<K, V> exten
      *
      * @return cached values
      */
-    @SuppressWarnings("unchecked")
-    public V[] values() {
+    public List<V> values() {
         List<V> values = new ArrayList<V>();
         for (int i = 0; i < segments.length; i++) {
             synchronized (segments[i]) {
@@ -150,7 +149,7 @@ public class ConcurrentCache<K, V> exten
                 }
             }
         }
-        return (V[]) values.toArray();
+        return values;
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java Wed Nov  2 19:21:34 2011
@@ -371,14 +371,13 @@ public class DbDataStore implements Data
                     // WHERE ID=? AND LAST_MODIFIED=?
                     int count = conHelper.update(updateSQL,
                             id, length, newModified, tempId, tempModified);
-                    if (count == 0) {
-                        // update count is 0, meaning the last modified time of the
-                        // temporary row was changed - which means we need to
-                        // re-try using a new last modified date (a later one)
-                        // because we need to ensure the new last modified date
-                        // is _newer_ than the old (otherwise the garbage collection
-                        // could delete rows)
-                    } else {
+                    // If update count is 0, the last modified time of the
+                    // temporary row was changed - which means we need to
+                    // re-try using a new last modified date (a later one)
+                    // because we need to ensure the new last modified date
+                    // is _newer_ than the old (otherwise the garbage
+                    // collection could delete rows)
+                    if (count != 0) {
                         // update was successful
                         break;
                     }
@@ -702,13 +701,9 @@ public class DbDataStore implements Data
         selectAllSQL = getProperty(prop, "selectAll", selectAllSQL);
         selectDataSQL = getProperty(prop, "selectData", selectDataSQL);
         storeStream = getProperty(prop, "storeStream", storeStream);
-        if (STORE_SIZE_MINUS_ONE.equals(storeStream)) {
-            // ok
-        } else if (STORE_TEMP_FILE.equals(storeStream)) {
-            // ok
-        } else if (STORE_SIZE_MAX.equals(storeStream)) {
-            // ok
-        } else {
+        if (!STORE_SIZE_MINUS_ONE.equals(storeStream)
+                && !STORE_TEMP_FILE.equals(storeStream)
+                && !STORE_SIZE_MAX.equals(storeStream)) {
             String msg = "Unsupported Stream store mechanism: " + storeStream
                     + " supported are: " + STORE_SIZE_MINUS_ONE + ", "
                     + STORE_TEMP_FILE + ", " + STORE_SIZE_MAX;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java Wed Nov  2 19:21:34 2011
@@ -120,38 +120,42 @@ public class LockManagerImpl
          */
         @Override
         public void acquire() throws InterruptedException {
-        	if (Thread.interrupted()) throw new InterruptedException();
-        	Xid currentXid = TransactionContext.getCurrentXid();
+            if (Thread.interrupted()) {
+                throw new InterruptedException();
+            }
+            Xid currentXid = TransactionContext.getCurrentXid();
             synchronized(this) {
-            	if (currentXid == activeXid || (activeXid != null && isSameGlobalTx(currentXid))) { 
-                ++holds_;
-            	} else {
-            		try {  
-            			while (activeXid != null) 
-            				wait(); 
-            			activeXid = currentXid;
-            			holds_ = 1;
-            		} catch (InterruptedException ex) {
-            			notify();
-            			throw ex;
-            		}
-            	}
+                if (currentXid == activeXid || (activeXid != null && isSameGlobalTx(currentXid))) { 
+                    ++holds_;
+                } else {
+                    try {  
+                        while (activeXid != null) {
+                            wait(); 
+                        }
+                        activeXid = currentXid;
+                        holds_ = 1;
+                    } catch (InterruptedException ex) {
+                        notify();
+                        throw ex;
+                    }
+                }
             }
         }
-        
+
         /**
          * {@inheritDoc}
          */
         @Override
         public synchronized void release()  {
-        	Xid currentXid = TransactionContext.getCurrentXid();
-            if (activeXid != null && !isSameGlobalTx(currentXid))
+            Xid currentXid = TransactionContext.getCurrentXid();
+            if (activeXid != null && !isSameGlobalTx(currentXid)) {
                 throw new Error("Illegal Lock usage"); 
+            }
 
-              if (--holds_ == 0) {
+            if (--holds_ == 0) {
                 activeXid = null;
                 notify(); 
-              }
+            }
         }
     };
 
@@ -789,10 +793,8 @@ public class LockManagerImpl
             PathMap.Element<LockInfo> element = lockMap.map(path, true);
             if (element != null) {
                 LockInfo info = element.get();
-                if (info != null) {
-                    if (info.isLockHolder(session)) {
-                        // nothing to do
-                    } else if (info.getLockHolder() == null) {
+                if (info != null && !info.isLockHolder(session)) {
+                    if (info.getLockHolder() == null) {
                         info.setLockHolder(session);
                         if (info instanceof InternalLockInfo) {
                             session.addListener((InternalLockInfo) info);
@@ -830,9 +832,7 @@ public class LockManagerImpl
                 if (info != null) {
                     if (info.isLockHolder(session)) {
                         info.setLockHolder(null);
-                    } else if (info.getLockHolder() == null) {
-                        // nothing to do
-                    } else {
+                    } else if (info.getLockHolder() != null) {
                         String msg = "Cannot remove lock token: lock held by other session.";
                         log.warn(msg);
                         info.throwLockException(msg, session);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XAEnvironment.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XAEnvironment.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XAEnvironment.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/XAEnvironment.java Wed Nov  2 19:21:34 2011
@@ -272,10 +272,8 @@ class XAEnvironment {
             NodeId id = LockInfo.parseLockToken(lt);
             NodeImpl node = (NodeImpl) session.getItemManager().getItem(id);
             LockInfo info = getLockInfo(node);
-            if (info != null) {
-                if (info.isLockHolder(session)) {
-                    // nothing to do
-                } else if (info.getLockHolder() == null) {
+            if (info != null && !info.isLockHolder(session)) {
+                if (info.getLockHolder() == null) {
                     info.setLockHolder(session);
                 } else {
                     String msg = "Cannot add lock token: lock already held by other session.";
@@ -307,9 +305,7 @@ class XAEnvironment {
             if (info != null) {
                 if (info.isLockHolder(session)) {
                     info.setLockHolder(null);
-                } else if (info.getLockHolder() == null) {
-                    // nothing to do
-                } else {
+                } else if (info.getLockHolder() != null) {
                     String msg = "Cannot remove lock token: lock held by other session.";
                     log.warn(msg);
                     throw new LockException(msg);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleDumper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleDumper.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleDumper.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleDumper.java Wed Nov  2 19:21:34 2011
@@ -160,11 +160,9 @@ public class BundleDumper {
 
         // mixin types
         int mn = readVarInt((b >> 7) & 1, 1);
-        if (mn == 0) {
-            // 0
-        } else if (mn == 1) {
+        if (mn == 1) {
             buffer.append("mixing type:").append(readName()).append("\n");
-        } else {
+        } else if (mn > 1) {
             buffer.append("mixing type count:").append(mn).append("\n");
             for (int i = 0; i < mn; i++) {
                 buffer.append("mixing type:").append(readName()).append("\n");
@@ -187,11 +185,9 @@ public class BundleDumper {
 
         // read shared set
         int sn = readVarInt((b >> 1) & 1, 1);
-        if (sn == 0) {
-            // 0
-        } else if (sn == 1) {
+        if (sn == 1) {
             buffer.append("shared set:").append(readNodeId()).append("\n");
-        } else {
+        } else if (sn > 1) {
             buffer.append("shared set count:").append(sn).append("\n");
             for (int i = 0; i < sn; i++) {
                 buffer.append("shared set:").append(readNodeId()).append("\n");

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CaseTermQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CaseTermQuery.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CaseTermQuery.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CaseTermQuery.java Wed Nov  2 19:21:34 2011
@@ -142,10 +142,6 @@ abstract class CaseTermQuery extends Mul
                             int compare = currentTerm.compareTo(termText);
                             if (compare == 0) {
                                 orderedTerms.put(t, terms.docFreq());
-                            } else if (compare < 0) {
-                                // try next one
-                            } else {
-                                // compare > 0
                             }
                         } else {
                             break;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/MLRUItemStateCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/MLRUItemStateCache.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/MLRUItemStateCache.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/MLRUItemStateCache.java Wed Nov  2 19:21:34 2011
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.core.state;
 
+import java.util.List;
+
 import org.apache.commons.collections.map.LinkedMap;
 import org.apache.jackrabbit.core.cache.CacheManager;
 import org.apache.jackrabbit.core.cache.ConcurrentCache;
@@ -73,7 +75,8 @@ public class MLRUItemStateCache implemen
      * {@inheritDoc}
      */
     public ItemState[] retrieveAll() {
-        return cache.values();
+        List<ItemState> values = cache.values();
+        return values.toArray(new ItemState[values.size()]);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java Wed Nov  2 19:21:34 2011
@@ -109,7 +109,7 @@ class NodeStateMerger {
                     ArrayList<ChildNodeEntry> removed = new ArrayList<ChildNodeEntry>();
 
                     for (ChildNodeEntry cne : state.getAddedChildNodeEntries()) {
-
+                        // locally added?
                         if (context.isAdded(cne.getId()) || context.isModified(cne.getId())) {
                             // a new child node entry has been added to this state;
                             // check for name collisions with other state
@@ -125,17 +125,14 @@ class NodeStateMerger {
                             }
 
                             added.add(cne);
-                        } else {
-                            // externally added
                         }
                     }
 
                     for (ChildNodeEntry cne : state.getRemovedChildNodeEntries()) {
+                        // locally removed?
                         if (context.isDeleted(cne.getId()) || context.isModified(cne.getId())) {
                             // a child node entry has been removed from this node state
                             removed.add(cne);
-                        } else {
-                            // externally removed
                         }
                     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java Wed Nov  2 19:21:34 2011
@@ -1187,13 +1187,11 @@ public class SharedItemStateManager
                 boolean addedAndRemoved = changeLog.has(removedNodeState.getId());
                 if (!addedAndRemoved) {
 
-                    // Check the old parent
+                    // Check the old parent; it should be either also deleted
+                    // or at least modified to reflect the removal of a child
                     NodeId oldParentId = overlayedState.getParentId();
-                    if (changeLog.deleted(oldParentId)) {
-                        // parent has been deleted as well
-                    } else if (changeLog.isModified(oldParentId)) {
-                        // the modified state will be check later on
-                    } else {
+                    if (!changeLog.deleted(oldParentId)
+                            && !changeLog.isModified(oldParentId)) {
                         String message = "Node with id " + id
                                 + " has been removed, but the parent node isn't part of the changelog " + oldParentId;
                         log.error(message);
@@ -1203,15 +1201,11 @@ public class SharedItemStateManager
                     // Get the original list of child ids
                     for (ChildNodeEntry entry : overlayedState.getChildNodeEntries()) {
 
-                        // Check the next child
+                        // Check the next child; it should be either also deleted
+                        // or at least modified to reflect being moved elsewhere
                         NodeId childId = entry.getId();
-
-                        if (changeLog.deleted(childId)) {
-                            // child has been deleted as well
-                        } else if (changeLog.isModified(childId)) {
-
-                            // the modified state will be check later on
-                        } else {
+                        if (!changeLog.deleted(childId)
+                                && !changeLog.isModified(childId)) {
                             String message = "Node with id " + id
                                     + " has been removed, but the old child node isn't part of the changelog "
                                     + childId;
@@ -1317,13 +1311,10 @@ public class SharedItemStateManager
                     checkParent(changeLog, modifiedNodeState, parentId);
                 }
 
-                // Check whether this node is the root node
-                if (parentId == null && oldParentId == null) {
-                    // The root node can be ignored
-
-                } else if (!parentId.equals(oldParentId)) {
-
-                    // This node has been moved, check whether the parent has been modified as well
+                if (!(parentId == null && oldParentId == null)
+                        && !parentId.equals(oldParentId)) {
+                    // This node (not the root) has been moved; check
+                    // whether the parent has been modified as well
                     if (changeLog.has(parentId)) {
                         checkParent(changeLog, modifiedNodeState, parentId);
                     } else if (!isShareable(modifiedNodeState)) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java Wed Nov  2 19:21:34 2011
@@ -109,11 +109,8 @@ class InternalFrozenNodeImpl extends Int
                         mixins.add(value.getName());
                     }
                 }
-            } else if (prop.getName().equals(NameConstants.JCR_PRIMARYTYPE)) {
-                // ignore
-            } else if (prop.getName().equals(NameConstants.JCR_UUID)) {
-                // ignore
-            } else {
+            } else if (!prop.getName().equals(NameConstants.JCR_PRIMARYTYPE)
+                    && !prop.getName().equals(NameConstants.JCR_UUID)) {
                 propList.add(prop);
             }
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplMerge.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplMerge.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplMerge.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplMerge.java Wed Nov  2 19:21:34 2011
@@ -331,13 +331,12 @@ abstract public class VersionManagerImpl
                 // - If V' is an eventual predecessor of V or if V and V' are identical (i.e., are
                 // actually the same version), then the merge result for N is leave.
                 return null;
-            } else {
-                // - If V is neither an eventual successor of, eventual predecessor of, nor
-                // identical with V', then the merge result for N is failed. This is the case
-                // where N and N' represent divergent branches of the version graph.
-
-                // failed is covered below
             }
+            // - If V is neither an eventual successor of, eventual predecessor of, nor
+            // identical with V', then the merge result for N is failed. This is the case
+            // where N and N' represent divergent branches of the version graph.
+
+            // failed is covered below
         } else {
             // If N is currently checked-out then:
             if (v.equals(vp) || v.isMoreRecent(vp)) {
@@ -345,12 +344,11 @@ abstract public class VersionManagerImpl
                 //   actually the same version), then the merge result for
                 //   N is leave.
                 return null;
-            } else {
-                // - If any other relationship holds between V and V', then the merge result
-                //   for N is fail.
-
-                // failed is covered below
             }
+            // - If any other relationship holds between V and V', then the merge result
+            //   for N is fail.
+
+            // failed is covered below
         }
 
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/AccessControlImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/AccessControlImporter.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/AccessControlImporter.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/AccessControlImporter.java Wed Nov  2 19:21:34 2011
@@ -223,12 +223,10 @@ public class AccessControlImporter exten
         } else {
             switch (status) {
                 case STATUS_AC_FOLDER:
-                    if (AccessControlConstants.NT_REP_ACCESS_CONTROL.equals(ntName)) {
-                        // yet another intermediate node -> keep status
-                    } else if (AccessControlConstants.NT_REP_PRINCIPAL_ACCESS_CONTROL.equals(ntName)) {
+                    if (AccessControlConstants.NT_REP_PRINCIPAL_ACCESS_CONTROL.equals(ntName)) {
                         // the start of a principal-based acl
                         status = STATUS_PRINCIPAL_AC;
-                    } else {
+                    } else if (!AccessControlConstants.NT_REP_ACCESS_CONTROL.equals(ntName)) {
                         // illegal node type.
                         throw new ConstraintViolationException("Unexpected node type " + ntName + ". Should be rep:AccessControl or rep:PrincipalAccessControl.");
                     }
@@ -238,10 +236,7 @@ public class AccessControlImporter exten
                     if (AccessControlConstants.NT_REP_ACCESS_CONTROL.equals(ntName)) {
                         // some intermediate path between principal paths.
                         status = STATUS_AC_FOLDER;
-                    } else if (AccessControlConstants.NT_REP_PRINCIPAL_ACCESS_CONTROL.equals(ntName)) {
-                        // principal-based ac node underneath another one
-                        // keep status
-                    } else {
+                    } else if (!AccessControlConstants.NT_REP_PRINCIPAL_ACCESS_CONTROL.equals(ntName)) {
                         // the start the acl definition itself
                         checkDefinition(childInfo, AccessControlConstants.N_POLICY, AccessControlConstants.NT_REP_ACL);
                         status = STATUS_ACL;

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/BTreeManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/BTreeManager.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/BTreeManager.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/BTreeManager.java Wed Nov  2 19:21:34 2011
@@ -210,7 +210,9 @@ public class BTreeManager implements Tre
         SizedIterator<Node> nodes = getNodes(node);
         long count = nodes.getSize();
         if (count < 0) {
-            for (count = 0; nodes.hasNext(); count++, nodes.next());
+            for (count = 0; nodes.hasNext(); count++) {
+                nodes.next();
+            }
         }
 
         if (count == 0) {
@@ -232,7 +234,9 @@ public class BTreeManager implements Tre
         SizedIterator<Property> properties = getProperties(node);
         long count = properties.getSize();
         if (count < 0) {
-            for (count = 0; properties.hasNext(); count++, properties.next());
+            for (count = 0; properties.hasNext(); count++) {
+                properties.next();
+            }
         }
 
         if (count == 0) {

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/Rank.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/Rank.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/Rank.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/Rank.java Wed Nov  2 19:21:34 2011
@@ -228,12 +228,19 @@ public class Rank<T> {
         // Partition values around pivot
         while (lo < hi) {
             // Find values to swap around the pivot
-            while (order.compare(values[lo], values[pivot]) < 0) lo++;
-            while (order.compare(values[hi], values[pivot]) > 0) hi--;
+            while (order.compare(values[lo], values[pivot]) < 0) {
+                lo++;
+            }
+            while (order.compare(values[hi], values[pivot]) > 0) {
+                hi--;
+            }
             if (lo < hi) {
                 // Swap values and keep track of pivot position in case the pivot itself is swapped
-                if (lo == pivot) pivot = hi;
-                else if (hi == pivot) pivot = lo;
+                if (lo == pivot) {
+                    pivot = hi;
+                } else if (hi == pivot) {
+                    pivot = lo;
+                }
                 swap(lo, hi);
                 lo++;
                 hi--;

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/sql2/Parser.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/sql2/Parser.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/sql2/Parser.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/sql2/Parser.java Wed Nov  2 19:21:34 2011
@@ -936,9 +936,9 @@ public class Parser {
             if (types[i] != CHAR_VALUE) {
                 throw getSyntaxError();
             }
-            while (types[++i] == CHAR_VALUE) {
-                // go until the first non-number
-            }
+            do {
+                i++; // go until the first non-number
+            } while (types[i] == CHAR_VALUE);
         }
         parseIndex = i;
         String sub = statement.substring(start, i);

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/QueryObjectModelFactoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/QueryObjectModelFactoryTest.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/QueryObjectModelFactoryTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/QueryObjectModelFactoryTest.java Wed Nov  2 19:21:34 2011
@@ -222,7 +222,7 @@ public class QueryObjectModelFactoryTest
             Comparison comp = qf.comparison(op1, operator, op2);
             assertTrue("Not a PropertyValue operand", comp.getOperand1() instanceof PropertyValue);
             assertTrue("Not a BindVariableValue operand", comp.getOperand2() instanceof BindVariableValue);
-            assertEquals("Wrong operator", operator.toString(), comp.getOperator());
+            assertEquals("Wrong operator", operator, comp.getOperator());
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java Wed Nov  2 19:21:34 2011
@@ -323,13 +323,11 @@ public class ItemDefinitionProviderImpl 
                                 throw new ConstraintViolationException("ambiguous property definitions found: " + match + " vs " + pd);
                             }
 
-                            if (match != null && match.getRequiredType() == PropertyType.STRING) {
-                                // If we already found a match, and that was of PropertyType.STRING,
-                                // then do not overwrite it. The whole reason there are multiple
-                                // potential matches is that the client did not specify the type,
-                                // thus obviously specified a String.
-                            }
-                            else {
+                            // If we already found a match, and that was of PropertyType.STRING,
+                            // then do not overwrite it. The whole reason there are multiple
+                            // potential matches is that the client did not specify the type,
+                            // thus obviously specified a String.
+                            if (match == null || match.getRequiredType() != PropertyType.STRING) {
                                 // found best possible match
                                 match = pd;
                             }

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathParser.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathParser.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathParser.java Wed Nov  2 19:21:34 2011
@@ -43,6 +43,8 @@ public class PathParser {
     private static final int STATE_URI = 9;
     private static final int STATE_URI_END = 10;
 
+    private static final char EOF = (char) -1;
+
     /**
      * Parses <code>jcrPath</code> into a <code>Path</code> object using
      * <code>resolver</code> to convert prefixes into namespace URI's. If
@@ -198,9 +200,6 @@ public class PathParser {
                              IdentifierResolver identifierResolver, PathFactory factory,
                              boolean normalizeIdentifier)
             throws MalformedPathException, IllegalNameException, NamespaceException {
-        
-        final char EOF = (char) -1;
-
         // check for length
         int len = jcrPath == null ? 0 : jcrPath.length();
 
@@ -318,9 +317,8 @@ public class PathParser {
                         builder.addLast(factory.getParentElement());
                         lastPos = pos;
                         state = STATE_PREFIX_START;
-                    } else if (state == STATE_PREFIX_START && c == EOF) {
-                        // ignore trailing slash
-                    } else if (state != STATE_URI) {
+                    } else if (state != STATE_URI
+                            && !(state == STATE_PREFIX_START && c == EOF)) { // ignore trailing slash
                         throw new MalformedPathException("'" + jcrPath + "' is not a valid path. '" + c + "' not a valid name character.");
                     }
                     break;
@@ -346,9 +344,7 @@ public class PathParser {
                         }
                         state = STATE_NAME_START;
                         // don't reset the lastPos/pos since prefix+name are passed together to the NameResolver
-                    } else if (state == STATE_IDENTIFIER || state == STATE_URI) {
-                        // nothing do
-                    } else {
+                    } else if (state != STATE_IDENTIFIER && state != STATE_URI) {
                         throw new MalformedPathException("'" + jcrPath + "' is not a valid path. '" + c + "' not valid name character");
                     }
                     break;
@@ -361,9 +357,7 @@ public class PathParser {
                         state = STATE_INDEX;
                         name = jcrPath.substring(lastPos, pos - 1);
                         lastPos = pos;
-                    } else if (state == STATE_IDENTIFIER) {
-                        // nothing do
-                    } else {
+                    } else if (state != STATE_IDENTIFIER) {
                         throw new MalformedPathException("'" + jcrPath + "' is not a valid path. '" + c + "' not a valid name character.");
                     }
                     break;
@@ -379,9 +373,7 @@ public class PathParser {
                             throw new MalformedPathException("'" + jcrPath + "' is not a valid path. Index number invalid: " + index);
                         }
                         state = STATE_INDEX_END;
-                    } else if (state == STATE_IDENTIFIER) {
-                        // nothing do
-                    } else {
+                    } else if (state != STATE_IDENTIFIER) {
                         throw new MalformedPathException("'" + jcrPath + "' is not a valid path. '" + c + "' not a valid name character.");
                     }
                     break;

Modified: jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/JcrClient.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/JcrClient.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/JcrClient.java (original)
+++ jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/JcrClient.java Wed Nov  2 19:21:34 2011
@@ -199,14 +199,16 @@ public class JcrClient {
         while (!exit) {
             try {
                 String input = reader.readLine("[" + this.getPrompt() + "] > ");
-                
+                if (input == null) {
+                    input = "exit";
+                } else {
+                    input = input.trim();
+                }
                 log.debug("running: " + input);
-                if (input.trim().equals("exit") || input.trim().equals("quit")) { // exit?
+                if (input.equals("exit") || input.equals("quit")) { // exit?
                     exit = true;
                     System.out.println("Good bye...");
-                } else if (input.trim().length() == 0) {
-                    // Do nothing
-                } else {
+                } else if (input.length() > 0) {
                     this.runCommand(input);
                 }
             } catch (JcrParserException e) {

Modified: jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/JcrParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/JcrParser.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/JcrParser.java (original)
+++ jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/JcrParser.java Wed Nov  2 19:21:34 2011
@@ -42,8 +42,7 @@ public class JcrParser {
             ConfigParser parser = new ConfigParser();
             parser.parse(JcrParser.class.getResource("command.xml"));
         } catch (Exception e) {
-            e.printStackTrace();
-            log.error(e);
+            log.error("Failed to parse command.xml", e);
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/fs/ImportFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/fs/ImportFileSystem.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/fs/ImportFileSystem.java (original)
+++ jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/fs/ImportFileSystem.java Wed Nov  2 19:21:34 2011
@@ -141,19 +141,6 @@ public class ImportFileSystem implements
     }
 
     /**
-     * @param name
-     *        the file name
-     * @return the extension for the given file name
-     */
-    private String getExtension(String name) {
-        String ext = null;
-        if (name.lastIndexOf('.') != -1) {
-            ext = name.substring(name.lastIndexOf('.') + 1);
-        }
-        return ext;
-    }
-
-    /**
      * @return the from key
      */
     public String getSrcFsPathKey() {

Modified: jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/info/AbstractLsNodes.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/info/AbstractLsNodes.java?rev=1196770&r1=1196769&r2=1196770&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/info/AbstractLsNodes.java (original)
+++ jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/info/AbstractLsNodes.java Wed Nov  2 19:21:34 2011
@@ -45,7 +45,7 @@ import org.apache.jackrabbit.standalone.
  * <li>referenceableKey</li>
  * <li>lockedKey</li>
  * <li>hasLockKey</li>
- * <li>new_Key</li>
+ * <li>newKey</li>
  * <li>modifiedKey</li>
  * </ul>
  */
@@ -87,7 +87,7 @@ public abstract class AbstractLsNodes ex
     private String hasLockKey = "hasLock";
 
     /** show is new */
-    private String new_Key = "new";
+    private String newKey = "new";
 
     /** show is modified */
     private String modifiedKey = "modified";
@@ -186,7 +186,7 @@ public abstract class AbstractLsNodes ex
         }
 
         // is new
-        if (oh.isNew_()) {
+        if (oh.isNew()) {
             widths.add(new Integer(this.longWidth));
             texts.add(Boolean.toString(n.isNew()));
         }
@@ -309,7 +309,7 @@ public abstract class AbstractLsNodes ex
         }
 
         // is new
-        if (oh.isNew_()) {
+        if (oh.isNew()) {
             widths.add(new Integer(this.longWidth));
             texts.add(bundle.getString("word.new"));
         }
@@ -470,7 +470,7 @@ public abstract class AbstractLsNodes ex
             referenceable = getFlag(referenceableKey);
             locked = getFlag(lockedKey);
             hasLock = getFlag(hasLockKey);
-            new_ = getFlag(new_Key);
+            new_ = getFlag(newKey);
             modified = getFlag(modifiedKey);
             lockToken = getFlag(lockTokenKey);
         }
@@ -513,7 +513,7 @@ public abstract class AbstractLsNodes ex
         /**
          * @return Returns the new_.
          */
-        public boolean isNew_() {
+        public boolean isNew() {
             return new_;
         }
 
@@ -647,18 +647,18 @@ public abstract class AbstractLsNodes ex
     }
 
     /**
-     * @return Returns the new_Key.
+     * @return Returns the newKey.
      */
-    public String getNew_Key() {
-        return new_Key;
+    public String getNewKey() {
+        return newKey;
     }
 
     /**
-     * @param new_Key
+     * @param newKey
      *        The new_Key to set.
      */
-    public void setNew_Key(String new_Key) {
-        this.new_Key = new_Key;
+    public void setNewKey(String newKey) {
+        this.newKey = newKey;
     }
 
     /**



Mime
View raw message