jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r158098 - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: ItemManager.java NamespaceRegistryImpl.java PropertyImpl.java nodetype/NodeTypeImpl.java xml/DocViewImportHandler.java
Date Fri, 18 Mar 2005 16:55:05 GMT
Author: stefan
Date: Fri Mar 18 08:55:03 2005
New Revision: 158098

URL: http://svn.apache.org/viewcvs?view=rev&rev=158098
Log:
JCR-62 import must not ignore xml prefixed attributes:
add "xml" as built-in and reserved namespace, anticipating spec change in 0.16.4

+ minor cosmetical changes

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java?view=diff&r1=158097&r2=158098
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java Fri Mar
18 08:55:03 2005
@@ -426,8 +426,6 @@
             throw new AccessDeniedException("cannot read item " + parentId);
         }
 
-        ArrayList childIds = new ArrayList();
-
         ItemState state;
         try {
             state = itemStateProvider.getItemState(parentId);
@@ -447,6 +445,7 @@
             throw new RepositoryException(msg);
         }
         NodeState nodeState = (NodeState) state;
+        ArrayList childIds = new ArrayList();
         Iterator iter = nodeState.getChildNodeEntries().iterator();
 
         while (iter.hasNext()) {

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java?view=diff&r1=158097&r2=158098
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
Fri Mar 18 08:55:03 2005
@@ -109,6 +109,9 @@
                 // sv:
                 prefixToURI.put(NS_SV_PREFIX, NS_SV_URI);
                 uriToPrefix.put(NS_SV_URI, NS_SV_PREFIX);
+                // xml: 
+                prefixToURI.put(NS_XML_PREFIX, NS_XML_URI);
+                uriToPrefix.put(NS_XML_URI, NS_XML_PREFIX);
 
                 // persist mappings
                 store();

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java?view=diff&r1=158097&r2=158098
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java Fri Mar
18 08:55:03 2005
@@ -124,6 +124,53 @@
     }
 
     /**
+     * Determines the length of the given value.
+     * @param value value whose length should be determined
+     * @return the length of the given value
+     * @throws RepositoryException if an error occurs
+     * @see javax.jcr.Property#getLength()
+     * @see javax.jcr.Property#getLengths()
+     */
+    protected long getLength(InternalValue value) throws RepositoryException {
+       switch (value.getType()) {
+            case PropertyType.STRING:
+            case PropertyType.LONG:
+            case PropertyType.DOUBLE:
+                return value.toString().length();
+
+            case PropertyType.NAME:
+                QName name = (QName) value.internalValue();
+                try {
+                    return name.toJCRName(session.getNamespaceResolver()).length();
+                } catch (NoPrefixDeclaredException npde) {
+                    // should never happen...
+                    String msg = safeGetJCRPath()
+                            + ": the value represents an invalid name";
+                    log.debug(msg);
+                    throw new RepositoryException(msg, npde);
+                }
+
+            case PropertyType.PATH:
+                Path path = (Path) value.internalValue();
+                try {
+                    return path.toJCRPath(session.getNamespaceResolver()).length();
+                } catch (NoPrefixDeclaredException npde) {
+                    // should never happen...
+                    String msg = safeGetJCRPath()
+                            + ": the value represents an invalid path";
+                    log.debug(msg);
+                    throw new RepositoryException(msg, npde);
+                }
+
+            case PropertyType.BINARY:
+                BLOBFileValue blob = (BLOBFileValue) value.internalValue();
+                return blob.getLength();
+        }
+
+        return -1;
+    }
+
+    /**
      * @param values
      * @param type
      * @throws ConstraintViolationException
@@ -1051,42 +1098,11 @@
 
         InternalValue[] values = ((PropertyState) state).getValues();
         if (values.length == 0) {
-            return 0;
+            // should never be the case, but being a little paranoid can't hurt...
+            log.warn(safeGetJCRPath() + ": single-valued property with no value");
+            return -1;
         }
-        InternalValue value = values[0];
-        switch (value.getType()) {
-            case PropertyType.STRING:
-            case PropertyType.LONG:
-            case PropertyType.DOUBLE:
-                return value.toString().length();
-
-            case PropertyType.NAME:
-                QName name = (QName) value.internalValue();
-                try {
-                    return name.toJCRName(session.getNamespaceResolver()).length();
-                } catch (NoPrefixDeclaredException npde) {
-                    // should never happen...
-                    String msg = safeGetJCRPath() + ": the value represents an invalid name";
-                    log.debug(msg);
-                    throw new RepositoryException(msg, npde);
-                }
-
-            case PropertyType.PATH:
-                Path path = (Path) value.internalValue();
-                try {
-                    return path.toJCRPath(session.getNamespaceResolver()).length();
-                } catch (NoPrefixDeclaredException npde) {
-                    // should never happen...
-                    String msg = safeGetJCRPath() + ": the value represents an invalid path";
-                    log.debug(msg);
-                    throw new RepositoryException(msg, npde);
-                }
-
-            case PropertyType.BINARY:
-                BLOBFileValue blob = (BLOBFileValue) value.internalValue();
-                return blob.getLength();
-        }
-        return -1;
+        return getLength(values[0]);
     }
 
     /**
@@ -1104,45 +1120,7 @@
         InternalValue[] values = ((PropertyState) state).getValues();
         long[] lengths = new long[values.length];
         for (int i = 0; i < values.length; i++) {
-            long length = -1;
-            InternalValue value = values[i];
-            switch (value.getType()) {
-                case PropertyType.STRING:
-                case PropertyType.LONG:
-                case PropertyType.DOUBLE:
-                    length = value.toString().length();
-                    break;
-
-                case PropertyType.NAME:
-                    QName name = (QName) value.internalValue();
-                    try {
-                        length = name.toJCRName(session.getNamespaceResolver()).length();
-                    } catch (NoPrefixDeclaredException npde) {
-                        // should never happen...
-                        String msg = safeGetJCRPath() + ": the value represents an invalid
name";
-                        log.debug(msg);
-                        throw new RepositoryException(msg, npde);
-                    }
-                    break;
-
-                case PropertyType.PATH:
-                    Path path = (Path) value.internalValue();
-                    try {
-                        length = path.toJCRPath(session.getNamespaceResolver()).length();
-                    } catch (NoPrefixDeclaredException npde) {
-                        // should never happen...
-                        String msg = safeGetJCRPath() + ": the value represents an invalid
path";
-                        log.debug(msg);
-                        throw new RepositoryException(msg, npde);
-                    }
-                    break;
-
-                case PropertyType.BINARY:
-                    BLOBFileValue blob = (BLOBFileValue) value.internalValue();
-                    length = blob.getLength();
-                    break;
-            }
-            lengths[i] = length;
+            lengths[i] = getLength(values[i]);
         }
         return lengths;
     }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java?view=diff&r1=158097&r2=158098
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
Fri Mar 18 08:55:03 2005
@@ -28,7 +28,6 @@
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
-import javax.jcr.ValueFormatException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.NodeDef;
@@ -62,7 +61,8 @@
      * @param ntMgr      the node type manager associated with this node type
      * @param nsResolver namespace resolver
      */
-    NodeTypeImpl(EffectiveNodeType ent, NodeTypeDef ntd, NodeTypeManagerImpl ntMgr, NamespaceResolver
nsResolver) {
+    NodeTypeImpl(EffectiveNodeType ent, NodeTypeDef ntd,
+                 NodeTypeManagerImpl ntMgr, NamespaceResolver nsResolver) {
         this.ent = ent;
         this.ntMgr = ntMgr;
         this.nsResolver = nsResolver;

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java?view=diff&r1=158097&r2=158098
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java
Fri Mar 18 08:55:03 2005
@@ -143,11 +143,6 @@
 
             ArrayList props = new ArrayList(atts.getLength());
             for (int i = 0; i < atts.getLength(); i++) {
-                if (atts.getQName(i).startsWith("xml:")) {
-                    // skipping xml:space, xml:lang, etc.
-                    log.debug("skipping reserved/system attribute " + atts.getQName(i));
-                    continue;
-                }
                 QName propName;
                 if (atts.getURI(i) != null && !"".equals(atts.getURI(i))) {
                     propName = new QName(atts.getURI(i), atts.getLocalName(i));



Mime
View raw message