jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r326962 - in /incubator/jackrabbit/trunk/contrib/jcr-ext: ./ src/java/org/apache/jackrabbit/base/ src/java/org/apache/jackrabbit/name/ src/java/org/apache/jackrabbit/session/ src/java/org/apache/jackrabbit/session/nodetype/ src/java/org/apa...
Date Thu, 20 Oct 2005 18:11:59 GMT
Author: jukka
Date: Thu Oct 20 11:11:46 2005
New Revision: 326962

URL: http://svn.apache.org/viewcvs?rev=326962&view=rev
Log:
JCR-EXT: Drop the custom qualified name implementation in favor of the jackrabbit-commons
one.

Removed:
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/name/
Modified:
    incubator/jackrabbit/trunk/contrib/jcr-ext/project.xml
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseNode.java
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/session/SessionHelper.java
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/session/nodetype/SessionNodeDefinition.java
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/session/nodetype/SessionNodeType.java
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/state/nodetype/ItemDefinitionState.java
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/state/nodetype/NodeDefinitionState.java
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/state/nodetype/NodeTypeState.java
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/xml/DocumentViewExportVisitor.java

Modified: incubator/jackrabbit/trunk/contrib/jcr-ext/project.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/project.xml?rev=326962&r1=326961&r2=326962&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/project.xml (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/project.xml Thu Oct 20 11:11:46 2005
@@ -62,6 +62,11 @@
       <url>http://jcp.org/en/jsr/detail?id=170</url>
     </dependency>
     <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-commons</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
       <groupId>xerces</groupId>
       <artifactId>xercesImpl</artifactId>
       <version>2.6.2</version>

Modified: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseNode.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseNode.java?rev=326962&r1=326961&r2=326962&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseNode.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/base/BaseNode.java
Thu Oct 20 11:11:46 2005
@@ -363,12 +363,15 @@
      */
     public Node getNode(String relPath) throws PathNotFoundException,
             RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+        /* TODO: Path.resolve is no longer available
         Item item = Path.resolve(this, relPath);
         if (item.isNode()) {
             return (Node) item;
         } else {
             throw new PathNotFoundException("Node not found: " + relPath);
         }
+        */
     }
 
     /** Not implemented. {@inheritDoc} */
@@ -390,12 +393,15 @@
      */
     public Property getProperty(String relPath) throws PathNotFoundException,
             RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+        /* TODO: Path.resolve is no longer available
         Item item = Path.resolve(this, relPath);
         if (item.isNode()) {
             throw new PathNotFoundException("Property not found: " + relPath);
         } else {
             return (Property) item;
         }
+        */
     }
 
     /** Not implemented. {@inheritDoc} */

Modified: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/session/SessionHelper.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/session/SessionHelper.java?rev=326962&r1=326961&r2=326962&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/session/SessionHelper.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/session/SessionHelper.java
Thu Oct 20 11:11:46 2005
@@ -22,7 +22,7 @@
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.NodeType;
 
-import org.apache.jackrabbit.name.Name;
+import org.apache.jackrabbit.name.QName;
 
 /**
  * Helper class for accessing the namespaces and node types associated
@@ -51,14 +51,14 @@
      * @throws IllegalStateException if the namespace does not exist
      * @throws RuntimeException if a repository error occurs
      */
-    public String getName(Name name)
+    public String getName(QName name)
             throws IllegalStateException, RuntimeException {
         try {
             String prefix = session.getNamespacePrefix(name.getNamespaceURI());
             if (prefix.length() > 0) {
-                return prefix + ":" + name.getLocalPart();
+                return prefix + ":" + name.getLocalName();
             } else {
-                return name.getLocalPart();
+                return name.getLocalName();
             }
         } catch (NamespaceException e) {
             throw new IllegalStateException("Expected namespace not found. " + e.getMessage());
@@ -79,7 +79,7 @@
      * @throws IllegalStateException if the named node type does not exist
      * @throws RuntimeException      if a repository error occurs
      */
-    public NodeType getNodeType(Name name)
+    public NodeType getNodeType(QName name)
             throws IllegalStateException, RuntimeException {
         return getNodeType(getName(name));
     }

Modified: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/session/nodetype/SessionNodeDefinition.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/session/nodetype/SessionNodeDefinition.java?rev=326962&r1=326961&r2=326962&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/session/nodetype/SessionNodeDefinition.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/session/nodetype/SessionNodeDefinition.java
Thu Oct 20 11:11:46 2005
@@ -23,7 +23,7 @@
 import javax.jcr.nodetype.NodeType;
 
 import org.apache.jackrabbit.session.SessionHelper;
-import org.apache.jackrabbit.name.Name;
+import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.state.nodetype.NodeDefinitionState;
 
 /**
@@ -84,7 +84,7 @@
      */
     public NodeType[] getRequiredPrimaryTypes() {
         Set types = new HashSet();
-        Name[] names = state.getRequiredPrimaryTypeNames();
+        QName[] names = state.getRequiredPrimaryTypeNames();
         for (int i = 0; i < names.length; i++) {
             types.add(helper.getNodeType(names[i]));
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/session/nodetype/SessionNodeType.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/session/nodetype/SessionNodeType.java?rev=326962&r1=326961&r2=326962&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/session/nodetype/SessionNodeType.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/session/nodetype/SessionNodeType.java
Thu Oct 20 11:11:46 2005
@@ -25,7 +25,7 @@
 
 import org.apache.jackrabbit.session.SessionHelper;
 import org.apache.jackrabbit.base.nodetype.BaseNodeType;
-import org.apache.jackrabbit.name.Name;
+import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.state.nodetype.NodeDefinitionState;
 import org.apache.jackrabbit.state.nodetype.NodeTypeState;
 import org.apache.jackrabbit.state.nodetype.PropertyDefinitionState;
@@ -108,7 +108,7 @@
      * @see NodeType#getPrimaryItemName()
      */
     public String getPrimaryItemName() {
-        Name name = state.getPrimaryItemName();
+        QName name = state.getPrimaryItemName();
         if (name != null) {
             return helper.getName(name);
         } else {
@@ -129,7 +129,7 @@
      */
     public NodeType[] getDeclaredSupertypes() {
         Set types = new HashSet();
-        Name[] names = state.getSupertypeNames();
+        QName[] names = state.getSupertypeNames();
         for (int i = 0; i < names.length; i++) {
             types.add(helper.getNodeType(names[i]));
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/state/nodetype/ItemDefinitionState.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/state/nodetype/ItemDefinitionState.java?rev=326962&r1=326961&r2=326962&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/state/nodetype/ItemDefinitionState.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/state/nodetype/ItemDefinitionState.java
Thu Oct 20 11:11:46 2005
@@ -18,7 +18,7 @@
 
 import javax.jcr.version.OnParentVersionAction;
 
-import org.apache.jackrabbit.name.Name;
+import org.apache.jackrabbit.name.QName;
 
 /**
  * Item definition state. This base class contains the common
@@ -27,7 +27,7 @@
 public class ItemDefinitionState {
 
     /** The qualified name of the defined item. */
-    private Name name;
+    private QName name;
 
     /** The AutoCreated item definition property. */
     private boolean autoCreated;
@@ -58,7 +58,7 @@
      *
      * @return qualified name
      */
-    public Name getName() {
+    public QName getName() {
         return name;
     }
 
@@ -67,7 +67,7 @@
      *
      * @param name new qualified name
      */
-    public void setName(Name name) {
+    public void setName(QName name) {
         this.name = name;
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/state/nodetype/NodeDefinitionState.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/state/nodetype/NodeDefinitionState.java?rev=326962&r1=326961&r2=326962&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/state/nodetype/NodeDefinitionState.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/state/nodetype/NodeDefinitionState.java
Thu Oct 20 11:11:46 2005
@@ -19,7 +19,7 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.jackrabbit.name.Name;
+import org.apache.jackrabbit.name.QName;
 
 /**
  * Node definition state. Instances of this class are used to hold
@@ -28,7 +28,7 @@
 public class NodeDefinitionState extends ItemDefinitionState {
 
     /** Name of the default primary type of the defined node. */
-    private Name defaultPrimaryTypeName;
+    private QName defaultPrimaryTypeName;
 
     /** Names of the required primary types of the defined node. */
     private Set requiredPrimaryTypeNames;
@@ -49,7 +49,7 @@
      *
      * @return default primary type name
      */
-    public Name getDefaultPrimaryTypeName() {
+    public QName getDefaultPrimaryTypeName() {
         return defaultPrimaryTypeName;
     }
 
@@ -58,7 +58,7 @@
      *
      * @param defaultPrimaryType new default primary type name
      */
-    public void setDefaultPrimaryTypeName(Name defaultPrimaryType) {
+    public void setDefaultPrimaryTypeName(QName defaultPrimaryType) {
         this.defaultPrimaryTypeName = defaultPrimaryType;
     }
 
@@ -67,9 +67,9 @@
      *
      * @return type names
      */
-    public Name[] getRequiredPrimaryTypeNames() {
-        return (Name[]) requiredPrimaryTypeNames.toArray(
-                new Name[requiredPrimaryTypeNames.size()]);
+    public QName[] getRequiredPrimaryTypeNames() {
+        return (QName[]) requiredPrimaryTypeNames.toArray(
+                new QName[requiredPrimaryTypeNames.size()]);
     }
 
     /**
@@ -77,7 +77,7 @@
      *
      * @param requiredPrimaryTypeName type name
      */
-    public void addRequiredPrimaryTypeNames(Name requiredPrimaryTypeName) {
+    public void addRequiredPrimaryTypeName(QName requiredPrimaryTypeName) {
         requiredPrimaryTypeNames.add(requiredPrimaryTypeName);
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/state/nodetype/NodeTypeState.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/state/nodetype/NodeTypeState.java?rev=326962&r1=326961&r2=326962&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/state/nodetype/NodeTypeState.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/state/nodetype/NodeTypeState.java
Thu Oct 20 11:11:46 2005
@@ -19,7 +19,7 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.jackrabbit.name.Name;
+import org.apache.jackrabbit.name.QName;
 
 /**
  * Node type state. Instances of this class are used to hold
@@ -28,7 +28,7 @@
 public class NodeTypeState {
 
     /** Name of the node type. */
-    private Name name;
+    private QName name;
 
     /** The Mixin node type property. */
     private boolean mixin;
@@ -37,7 +37,7 @@
     private boolean hasOrderableChildNodes;
 
     /** Name of the primary item of the node type. */
-    private Name primaryItemName;
+    private QName primaryItemName;
 
     /** Names of the declared supertypes. */
     private Set supertypeNames;
@@ -64,7 +64,7 @@
      *
      * @return qualified name
      */
-    public Name getName() {
+    public QName getName() {
         return name;
     }
 
@@ -73,7 +73,7 @@
      *
      * @param name new qualified name
      */
-    public void setName(Name name) {
+    public void setName(QName name) {
         this.name = name;
     }
 
@@ -118,7 +118,7 @@
      *
      * @return primary item name
      */
-    public Name getPrimaryItemName() {
+    public QName getPrimaryItemName() {
         return primaryItemName;
     }
 
@@ -127,7 +127,7 @@
      *
      * @param primaryItemName new primary item name
      */
-    public void setPrimaryItemName(Name primaryItemName) {
+    public void setPrimaryItemName(QName primaryItemName) {
         this.primaryItemName = primaryItemName;
     }
 
@@ -136,9 +136,9 @@
      *
      * @return supertype names
      */
-    public Name[] getSupertypeNames() {
-        return (Name[])
-            supertypeNames.toArray(new Name[supertypeNames.size()]);
+    public QName[] getSupertypeNames() {
+        return (QName[])
+            supertypeNames.toArray(new QName[supertypeNames.size()]);
     }
 
     /**
@@ -146,7 +146,7 @@
      *
      * @param name supertype name
      */
-    public void addSupertypeName(Name name) {
+    public void addSupertypeName(QName name) {
         supertypeNames.add(name);
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/xml/DocumentViewExportVisitor.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/xml/DocumentViewExportVisitor.java?rev=326962&r1=326961&r2=326962&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/xml/DocumentViewExportVisitor.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/xml/DocumentViewExportVisitor.java
Thu Oct 20 11:11:46 2005
@@ -34,7 +34,11 @@
 import javax.jcr.ValueFormatException;
 
 import org.apache.commons.codec.binary.Base64;
-import org.apache.jackrabbit.name.Name;
+import org.apache.jackrabbit.name.IllegalNameException;
+import org.apache.jackrabbit.name.NoPrefixDeclaredException;
+import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.SessionNamespaceResolver;
+import org.apache.jackrabbit.name.UnknownPrefixException;
 import org.apache.xerces.util.XMLChar;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
@@ -127,15 +131,6 @@
  */
 public class DocumentViewExportVisitor implements ItemVisitor {
 
-    /** The JCR namespace URI. */
-    private static final String JCR_URI = "http://www.jcp.org/jcr/1.0";
-
-    /** The special jcr:xmltext property name. */
-    private static final Name XMLTEXT = new Name(JCR_URI, "xmltext");
-
-    /** The special jcr:xmlcharacters property name. */
-    private static final Name XMLCHARACTERS = new Name(JCR_URI, "xmlcharacters");
-
     /**
      * The SAX content handler for the serialized XML stream.
      */
@@ -215,7 +210,7 @@
             }
 
             // export current node
-            if (!node.getName().equals(XMLTEXT)) {
+            if (!node.getName().equals(QName.JCR_XMLTEXT)) {
                 exportNode(node);
             } else if (node != root) {
                 exportText(node);
@@ -279,10 +274,14 @@
     private void exportText(Node node)
             throws SAXException, RepositoryException {
         try {
-            Property property =
-                node.getProperty(XMLCHARACTERS.toJCRName(node.getSession()));
+            Property property = node.getProperty(
+                    QName.JCR_XMLCHARACTERS.toJCRName(
+                            new SessionNamespaceResolver(node.getSession())));
             char[] characters = property.getString().toCharArray();
             handler.characters(characters, 0, characters.length);
+        } catch (NoPrefixDeclaredException ex) {
+            throw new RepositoryException(
+                    "The JCR namespace prefix is not available", ex);
         } catch (PathNotFoundException ex) {
             // ignore empty jcr:xmltext nodes
         } catch (ValueFormatException ex) {
@@ -302,8 +301,8 @@
      */
     private void exportNode(Node node)
             throws SAXException, RepositoryException {
-        Name name = getName(node);
-        String localName = escapeName(name.getLocalPart());
+        QName name = getName(node);
+        String localName = escapeName(name.getLocalName());
         String prefixedName =
             node.getSession().getNamespacePrefix(name.getNamespaceURI())
             + ":" + localName;
@@ -326,7 +325,7 @@
 
         // End element
         handler.endElement(
-                name.getNamespaceURI(), name.getLocalPart(), node.getName());
+                name.getNamespaceURI(), name.getLocalName(), node.getName());
     }
 
     /**
@@ -339,26 +338,31 @@
      * @throws RepositoryException on repository errors
      */
     private Attributes getAttributes(Node node) throws RepositoryException {
-        AttributesImpl attributes = new AttributesImpl();
-
-        PropertyIterator properties = node.getProperties();
-        while (properties.hasNext()) {
-            Property property = properties.nextProperty();
-            /*
-            return !property.getName().equals(XMLCHARACTERS)
-            && (!skipBinary || property.getType() != PropertyType.BINARY);
-            */
-            if (includeProperty(property)) {
-                Name name = getName(property);
-                attributes.addAttribute(
-                        name.getNamespaceURI(),
-                        escapeName(name.getLocalPart()),
-                        escapeName(name.toJCRName(property.getSession())),
-                        "CDATA", escapeValue(property));
+        try {
+            AttributesImpl attributes = new AttributesImpl();
+            
+            PropertyIterator properties = node.getProperties();
+            while (properties.hasNext()) {
+                Property property = properties.nextProperty();
+                /*
+                 return !property.getName().equals(XMLCHARACTERS)
+                 && (!skipBinary || property.getType() != PropertyType.BINARY);
+                 */
+                if (includeProperty(property)) {
+                    QName name = getName(property);
+                    attributes.addAttribute(
+                            name.getNamespaceURI(),
+                            escapeName(name.getLocalName()),
+                            escapeName(name.toJCRName(
+                                    new SessionNamespaceResolver(property.getSession()))),
+                                    "CDATA", escapeValue(property));
+                }
             }
+            
+            return attributes;
+        } catch (NoPrefixDeclaredException e) {
+            throw new RepositoryException(e);
         }
-
-        return attributes;
     }
 
     /**
@@ -378,12 +382,18 @@
      * @throws RepositoryException on repository errors
      * @see Name
      */
-    private Name getName(Item item) throws RepositoryException {
-        String name = item.getName();
-        if (name.length() > 0) {
-            return Name.fromJCRName(item.getSession(), name);
-        } else {
-            return new Name("http://www.jcp.org/jcr/1.0", "root");
+    private QName getName(Item item) throws RepositoryException {
+        try {
+            String name = item.getName();
+            if (name.length() > 0) {
+                return QName.fromJCRName(name, new SessionNamespaceResolver(item.getSession()));
+            } else {
+                return QName.JCR_ROOT;
+            }
+        } catch (IllegalNameException e) {
+            throw new RepositoryException(e);
+        } catch (UnknownPrefixException e) {
+            throw new RepositoryException(e);
         }
     }
 



Mime
View raw message