jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r160315 - in incubator/jackrabbit/trunk/src: java/org/apache/jackrabbit/core/ java/org/apache/jackrabbit/core/state/ test/org/apache/jackrabbit/test/api/
Date Wed, 06 Apr 2005 18:05:47 GMT
Author: stefan
Date: Wed Apr  6 11:05:45 2005
New Revision: 160315

URL: http://svn.apache.org/viewcvs?view=rev&rev=160315
Log:
fixed incorrect test cases and fixed code that caused valid testcases to fail

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SysViewContentHandler.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/CachingHierarchyManager.java?view=diff&r1=160314&r2=160315
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
Wed Apr  6 11:05:45 2005
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.core;
 
 import org.apache.commons.collections.ReferenceMap;
-import org.apache.log4j.Logger;
 
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.PathNotFoundException;
@@ -37,8 +36,6 @@
  */
 public class CachingHierarchyManager implements HierarchyManager {
 
-    private static Logger log = Logger.getLogger(CachingHierarchyManager.class);
-
     private final HierarchyManager delegatee;
 
     // map of item id to list of paths
@@ -77,14 +74,16 @@
     /**
      * {@inheritDoc}
      */
-    public NodeId[] listParents(ItemId id) throws ItemNotFoundException, RepositoryException
{
+    public NodeId[] listParents(ItemId id)
+            throws ItemNotFoundException, RepositoryException {
         return delegatee.listParents(id);
     }
 
     /**
      * {@inheritDoc}
      */
-    public ItemId[] listChildren(NodeId id) throws ItemNotFoundException, RepositoryException
{
+    public ItemId[] listChildren(NodeId id)
+            throws ItemNotFoundException, RepositoryException {
         return delegatee.listChildren(id);
     }
 
@@ -114,14 +113,16 @@
     /**
      * {@inheritDoc}
      */
-    public synchronized Path getPath(ItemId id) throws ItemNotFoundException, RepositoryException
{
+    public synchronized Path getPath(ItemId id)
+            throws ItemNotFoundException, RepositoryException {
         return getAllPaths(id, false)[0];
     }
 
     /**
      * {@inheritDoc}
      */
-    public QName getName(ItemId itemId) throws ItemNotFoundException, RepositoryException
{
+    public QName getName(ItemId itemId)
+            throws ItemNotFoundException, RepositoryException {
         if (itemId.denotesNode()) {
             return getPath(itemId).getNameElement().getName();
         } else {
@@ -133,7 +134,8 @@
     /**
      * {@inheritDoc}
      */
-    public synchronized Path[] getAllPaths(ItemId id) throws ItemNotFoundException, RepositoryException
{
+    public synchronized Path[] getAllPaths(ItemId id)
+            throws ItemNotFoundException, RepositoryException {
         return getAllPaths(id, false);
     }
 

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java?view=diff&r1=160314&r2=160315
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java
Wed Apr  6 11:05:45 2005
@@ -520,9 +520,11 @@
                     }
                 }
                 if (entries.isEmpty()) {
-                    String msg = "failed to build path of " + nodeId + ": " + parent.getUUID()
+ " has no child entry for " + uuid;
+                    String msg = "failed to build path of " + nodeId
+                            + ": " + parent.getUUID()
+                            + " has no child entry for " + uuid;
                     log.debug(msg);
-                    throw new RepositoryException(msg);
+                    throw new ItemNotFoundException(msg);
                 }
                 n = entries.size() - 1;
                 while (n-- > 0) {

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java?view=diff&r1=160314&r2=160315
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java Wed Apr 
6 11:05:45 2005
@@ -1206,7 +1206,7 @@
                                 String msg = itemMgr.safeGetJCRPath(id)
                                         + " needs to be saved also.";
                                 log.debug(msg);
-                                throw new RepositoryException(msg);
+                                throw new ConstraintViolationException(msg);
                             }
                         }
                     }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java?view=diff&r1=160314&r2=160315
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java Wed Apr 
6 11:05:45 2005
@@ -364,10 +364,21 @@
         return genValues;
     }
 
+    /**
+     *
+     * @param name
+     * @param type
+     * @param multiValued
+     * @param status
+     * @return
+     * @throws ConstraintViolationException if no applicable property definition
+     *                                      could be found
+     * @throws RepositoryException if another error occurs
+     */ 
     protected PropertyImpl getOrCreateProperty(String name, int type,
                                                boolean multiValued,
                                                BitSet status)
-            throws RepositoryException {
+            throws ConstraintViolationException, RepositoryException {
         QName qName;
         try {
             qName = QName.fromJCRName(name, session.getNamespaceResolver());
@@ -379,10 +390,21 @@
         return getOrCreateProperty(qName, type, multiValued, status);
     }
 
+    /**
+     *
+     * @param name
+     * @param type
+     * @param multiValued
+     * @param status
+     * @return
+     * @throws ConstraintViolationException if no applicable property definition
+     *                                      could be found
+     * @throws RepositoryException if another error occurs
+     */
     protected synchronized PropertyImpl getOrCreateProperty(QName name, int type,
                                                             boolean multiValued,
                                                             BitSet status)
-            throws RepositoryException {
+            throws ConstraintViolationException, RepositoryException {
         status.clear();
 
         NodeState thisState = (NodeState) state;
@@ -814,11 +836,12 @@
      * @param nodeName
      * @param nodeTypeName
      * @return
-     * @throws RepositoryException if no applicable child node definition
-     *                             could be found
+     * @throws ConstraintViolationException if no applicable child node definition
+     *                                      could be found
+     * @throws RepositoryException if another error occurs
      */
     protected NodeDefImpl getApplicableChildNodeDef(QName nodeName, QName nodeTypeName)
-            throws RepositoryException {
+            throws ConstraintViolationException, RepositoryException {
         ChildNodeDef cnd = getEffectiveNodeType().getApplicableChildNodeDef(nodeName, nodeTypeName);
         return session.getNodeTypeManager().getNodeDef(new NodeDefId(cnd));
     }
@@ -831,12 +854,14 @@
      * @param type
      * @param multiValued
      * @return
-     * @throws RepositoryException if no applicable property definition
-     *                             could be found
+     * @throws ConstraintViolationException if no applicable property definition
+     *                                      could be found
+     * @throws RepositoryException if another error occurs
      */
     protected PropertyDefImpl getApplicablePropertyDef(QName propertyName,
-                                                       int type, boolean multiValued)
-            throws RepositoryException {
+                                                       int type,
+                                                       boolean multiValued)
+            throws ConstraintViolationException, RepositoryException {
         PropDef pd = getEffectiveNodeType().getApplicablePropertyDef(propertyName, type,
multiValued);
         return session.getNodeTypeManager().getPropDef(new PropDefId(pd));
     }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java?view=diff&r1=160314&r2=160315
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
Wed Apr  6 11:05:45 2005
@@ -319,6 +319,13 @@
                     String msg = id + ": the item has been removed externally.";
                     log.debug(msg);
                     throw new InvalidItemStateException(msg);
+                } catch (RepositoryException re) {
+                    // unable to build path, assume that it (or any of
+                    // its ancestors) has been removed externally
+                    String msg = id
+                            + ": the item seems to have been removed externally.";
+                    log.debug(msg);
+                    throw new InvalidItemStateException(msg);
                 }
             }
             return descendants.values().iterator();
@@ -350,13 +357,17 @@
                      * one of the parents of the specified item has been
                      * removed externally; as we don't know its path,
                      * we can't determine if it is a descendant;
-                     * ItemNotFoundException should only be thrown if
+                     * InvalidItemStateException should only be thrown if
                      * a descendant is affected;
-                     * => log warning and ignore for now
+                     * => throw InvalidItemStateException for now
                      * todo FIXME
                      */
-                    log.warn(id + ": inconsistent hierarchy state", infe);
-                    continue;
+                    // unable to build path, assume that it (or any of
+                    // its ancestors) has been removed externally
+                    String msg = id
+                            + ": the item seems to have been removed externally.";
+                    log.debug(msg);
+                    throw new InvalidItemStateException(msg);
                 }
                 boolean isDescendant = false;
                 /**

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SysViewContentHandler.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SysViewContentHandler.java?view=diff&r1=160314&r2=160315
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SysViewContentHandler.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SysViewContentHandler.java
Wed Apr  6 11:05:45 2005
@@ -338,8 +338,13 @@
             NamespaceRegistry nsr = session.getWorkspace().getNamespaceRegistry();
             String[] registeredPrefixes = nsr.getPrefixes();
             // check against the found prefixes
+/*
+            // invalid test: only the referenced namespaces need to be declared;
+            // apart from that, the 'xml' namespace, although registered,
+            // is never declared in the system view xml as this would be illegal
             checkCondition("Size of included prefixes is not the size of " +
                     "registered prefixes", registeredPrefixes.length == prefixes.size())
;
+*/
             for (int i=0; i<registeredPrefixes.length;i++) {
                 String prefix = registeredPrefixes[1];
                 String uri = nsr.getURI(prefix);



Mime
View raw message