jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r932957 [1/2] - in /jackrabbit/sandbox/jackrabbit-j3/src: main/java/org/apache/jackrabbit/j3/nodetype/ test/resources/ test/resources/org/ test/resources/org/apache/ test/resources/org/apache/jackrabbit/ test/resources/org/apache/jackrabbit...
Date Sun, 11 Apr 2010 17:50:42 GMT
Author: thomasm
Date: Sun Apr 11 17:50:41 2010
New Revision: 932957

URL: http://svn.apache.org/viewvc?rev=932957&view=rev
Log:
Some code for a Jackrabbit 3 prototype

Added:
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/CndParser.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeIteratorImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/resources/
    jackrabbit/sandbox/jackrabbit-j3/src/test/resources/org/
    jackrabbit/sandbox/jackrabbit-j3/src/test/resources/org/apache/
    jackrabbit/sandbox/jackrabbit-j3/src/test/resources/org/apache/jackrabbit/
    jackrabbit/sandbox/jackrabbit-j3/src/test/resources/org/apache/jackrabbit/j3/
    jackrabbit/sandbox/jackrabbit-j3/src/test/resources/org/apache/jackrabbit/j3/builtin_nodetypes.cnd
    jackrabbit/sandbox/jackrabbit-j3/src/test/resources/org/apache/jackrabbit/j3/test.cnd
Modified:
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/ItemDefinitionImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionTemplateImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeDefinitionImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeManagerImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeRegistry.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeTemplateImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionTemplateImpl.java

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/CndParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/CndParser.java?rev=932957&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/CndParser.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/CndParser.java Sun Apr 11 17:50:41 2010
@@ -0,0 +1,330 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.j3.nodetype;
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.nodetype.NodeDefinitionTemplate;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.nodetype.NodeTypeTemplate;
+import javax.jcr.nodetype.PropertyDefinitionTemplate;
+import javax.jcr.version.OnParentVersionAction;
+
+/**
+ * A CND (compact node type definition) reader.
+ */
+public class CndParser {
+
+//    private final Session session;
+    private final NodeTypeManager ntm;
+    private final NamespaceRegistry ntReg;
+    private final ValueFactory vf;
+    private final String content;
+    private final char[] contentChars;
+    private int parseIndex;
+    private String currentToken;
+    private ArrayList<NodeTypeTemplate> ntList = new ArrayList<NodeTypeTemplate>();
+
+    public CndParser(NodeTypeManager ntm, NamespaceRegistry ntReg, ValueFactory vf, String syntax) throws RepositoryException {
+        this.ntm = ntm;
+        this.ntReg = ntReg;
+        this.vf = vf;
+        this.content = syntax + "  ";
+        contentChars = this.content.toCharArray();
+        read();
+    }
+
+    @SuppressWarnings("unchecked")
+    public void parse() throws RepositoryException, ParseException {
+        while (!readIf("")) {
+            if (readIf("<")) {
+                String prefix = readString();
+                read("=");
+                String uri = readString();
+                ntReg.registerNamespace(prefix, uri);
+                read(">");
+            } else {
+                NodeTypeTemplate nt = ntm.createNodeTypeTemplate();
+                read("[");
+                nt.setName(readString());
+                read("]");
+                if (readIf(">")) {
+                    nt.setDeclaredSuperTypeNames(readList());
+                }
+                while (true) {
+                    if (readIf("orderable", "ord", "o")) {
+                        nt.setOrderableChildNodes(true);
+                    } else if (readIf("mixin", "mix", "m")) {
+                        nt.setMixin(true);
+                    } else if (readIf("abstract", "abs", "a")) {
+                        nt.setAbstract(true);
+                    } else if (readIf("noquery", "nq")) {
+                        nt.setQueryable(false);
+                    } else if (readIf("query", "q")) {
+                        nt.setQueryable(true);
+                    } else if (readIf("primaryitem", "!")) {
+                        nt.setPrimaryItemName(readString());
+                    } else {
+                        break;
+                    }
+                }
+                while (true) {
+                    if (readIf("-")) {
+                        PropertyDefinitionTemplate pd = ntm.createPropertyDefinitionTemplate();
+                        pd.setFullTextSearchable(true);
+                        pd.setQueryOrderable(true);
+                        if (readIf("*")) {
+                            pd.setName("*");
+                        } else {
+                            pd.setName(readString());
+                        }
+                        read("(");
+                        if (readIf("*", "undefined")) {
+                            pd.setRequiredType(PropertyType.UNDEFINED);
+                        } else if (readIf("uri")) {
+                            pd.setRequiredType(PropertyType.URI);
+                        } else if (readIf("weakreference")) {
+                            pd.setRequiredType(PropertyType.WEAKREFERENCE);
+                        } else {
+                            String s = readString();
+                            // all other types are title case
+                            s = s.toUpperCase().substring(0, 1) + s.substring(1).toLowerCase();
+                            pd.setRequiredType(PropertyType.valueFromName(s));
+                        }
+                        read(")");
+                        if (readIf("=")) {
+                            String[] list = readList();
+                            Value[] values = new Value[list.length];
+                            for (int i = 0; i < list.length; i++) {
+                                values[i] = vf.createValue(list[i], pd.getRequiredType());
+                            }
+                            pd.setDefaultValues(values);
+                        }
+                        while (true) {
+                            if (readIf("autocreated", "aut", "a")) {
+                                pd.setAutoCreated(true);
+                            } else if (readIf("mandatory", "man", "m")) {
+                                pd.setMandatory(true);
+                            } else if (readIf("protected", "pro", "p")) {
+                                pd.setProtected(true);
+                            } else if (readIf("multiple", "mul", "*")) {
+                                pd.setMultiple(true);
+                            } else if (readIf("queryops", "qop")) {
+                                pd.setAvailableQueryOperators(readString().split(","));
+                            } else if (readIf("nofulltext", "nof")) {
+                                pd.setFullTextSearchable(false);
+                            } else if (readIf("noqueryorder", "nqord")) {
+                                pd.setQueryOrderable(false);
+                            } else if (readIf("<")) {
+                                pd.setValueConstraints(readList());
+                            } else {
+                                String token = currentToken;
+                                if (readIf("copy", "version", "initialize", "compute", "ignore", "abort")) {
+                                    pd.setOnParentVersion(OnParentVersionAction.valueFromName(token.toUpperCase()));
+                                } else {
+                                    break;
+                                }
+                            }
+                        }
+                        nt.getPropertyDefinitionTemplates().add(pd);
+                    } else if (readIf("+")) {
+                        NodeDefinitionTemplate nd = ntm.createNodeDefinitionTemplate();
+                        nd.setName(readString());
+                        if (readIf("(")) {
+                            nd.setRequiredPrimaryTypeNames(readList());
+                            read(")");
+                        }
+                        if (readIf("=")) {
+                            nd.setDefaultPrimaryTypeName(readString());
+                        }
+                        while (true) {
+                            if (readIf("autocreated", "aut", "a")) {
+                                nd.setAutoCreated(true);
+                            } else if (readIf("mandatory", "man", "m")) {
+                                nd.setMandatory(true);
+                            } else if (readIf("protected", "pro", "p")) {
+                                nd.setProtected(true);
+                            } else if (readIf("sns", "*")) {
+                                nd.setSameNameSiblings(true);
+                            } else {
+                                String token = currentToken;
+                                if (readIf("copy", "version", "initialize", "compute", "ignore", "abort")) {
+                                    nd.setOnParentVersion(OnParentVersionAction.valueFromName(token.toUpperCase()));
+                                } else {
+                                    break;
+                                }
+                            }
+                        }
+                        nt.getNodeDefinitionTemplates().add(nd);
+                    } else {
+                        break;
+                    }
+                }
+                ntList.add(nt);
+            }
+        }
+    }
+
+    public List<NodeTypeTemplate> getNodeTypeTemplates() {
+        return ntList;
+    }
+
+    public void register(boolean allowUpdate) throws RepositoryException {
+        NodeTypeTemplate[] array = ntList.toArray(new NodeTypeTemplate[ntList.size()]);
+        ntm.registerNodeTypes(array, allowUpdate);
+    }
+
+    private String[] readList() throws ParseException {
+        ArrayList<String> list = new ArrayList<String>();
+        do {
+            list.add(readString());
+        } while (readIf(","));
+        return list.toArray(new String[list.size()]);
+    }
+
+    private String readString() throws ParseException {
+        String token = currentToken;
+        read();
+        if (token.startsWith("\'") || token.startsWith("\"")) {
+            return javaDecode(token.substring(1, token.length() - 1));
+        }
+        return token;
+    }
+
+    public String javaDecode(String s) throws ParseException {
+        StringBuilder buff = new StringBuilder(s.length());
+        for (int i = 0; i < s.length(); i++) {
+            char c = s.charAt(i);
+            if (c == '\\') {
+                if (i >= s.length()) {
+                    throw getParseException("String not terminated", s, s.length() - 1);
+                }
+                c = s.charAt(++i);
+                if (c == 'u') {
+                    // java.io.StreamTokenizer doesn't support \ u
+                    try {
+                        c = (char) (Integer.parseInt(s.substring(i + 1, i + 5), 16));
+                    } catch (NumberFormatException e) {
+                        throw getParseException("Invalid escape", s, i);
+                    }
+                    i += 4;
+                    buff.append(c);
+                } else {
+                    if (c >= '0' && c <= '9') {
+                        try {
+                            c = (char) (Integer.parseInt(s.substring(i, i + 3), 8));
+                        } catch (NumberFormatException e) {
+                            throw getParseException("Number format", s, i);
+                        }
+                        i += 2;
+                        buff.append(c);
+                    } else {
+                        int index = "trnbf\"\'\\".indexOf(c);
+                        if (index < 0) {
+                            throw getParseException("Invalid escape sequence", s, i);
+                        }
+                        buff.append("\t\r\n\b\f\"\'\\".charAt(index));
+                    }
+                }
+            } else {
+                buff.append(c);
+            }
+        }
+        return buff.toString();
+    }
+
+    private void read(String t) throws ParseException {
+        if (!currentToken.equals(t)) {
+            throw getParseException("Expected: " + t + " got: " + currentToken, content, parseIndex);
+        }
+        read();
+    }
+
+    private ParseException getParseException(String message, String s, int x) {
+        return new ParseException(message + " in \n" + s.substring(0, x) + "[*]" + s.substring(x), x);
+    }
+
+    private boolean readIf(String... tokens) {
+        for (String t : tokens) {
+            if (currentToken.equalsIgnoreCase(t)) {
+                read();
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private void read() {
+        int i = parseIndex;
+        char[] chars = contentChars;
+        while (true) {
+            if (i >= chars.length) {
+                currentToken = "";
+                return;
+            }
+            int start = i;
+            char c = chars[i++];
+            switch (c) {
+            case '\'':
+                while (chars[i] != '\'') {
+                    if (chars[i++] == '\\') {
+                        i++;
+                    }
+                }
+                i++;
+                break;
+            case '\"':
+                while (chars[i] != '\"') {
+                    if (chars[i++] == '\\') {
+                        i++;
+                    }
+                }
+                i++;
+                break;
+            case '/':
+                if (chars[i] == '/') {
+                    i = content.indexOf('\n', i);
+                } else if (chars[i] == '*') {
+                    i = content.indexOf("*/", i + 2) + 2;
+                }
+                continue;
+            default:
+                if ("<>=[]!-*+(),{}".indexOf(c) >= 0) {
+                    break;
+                } else if (c <= ' ') {
+                    continue;
+                } else {
+                    i--;
+                    while ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
+                            (c >= '0' && c <= '9') || c == ':' || c == '_') {
+                        c = chars[++i];
+                    }
+                    break;
+                }
+            }
+            currentToken = content.substring(start, i);
+            break;
+        }
+        parseIndex = i;
+    }
+}

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/ItemDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/ItemDefinitionImpl.java?rev=932957&r1=932956&r2=932957&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/ItemDefinitionImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/ItemDefinitionImpl.java Sun Apr 11 17:50:41 2010
@@ -18,47 +18,73 @@ package org.apache.jackrabbit.j3.nodetyp
 
 import javax.jcr.nodetype.ItemDefinition;
 import javax.jcr.nodetype.NodeType;
+import javax.jcr.version.OnParentVersionAction;
 import org.apache.jackrabbit.j3.mc.Val;
+import org.apache.jackrabbit.j3.util.Log;
+import org.apache.jackrabbit.j3.util.LogObject;
 
 /**
- * The item definition implementation.
+ * The implementation of the corresponding JCR interface.
  */
-public class ItemDefinitionImpl implements ItemDefinition {
+public class ItemDefinitionImpl implements ItemDefinition, LogObject {
 
     protected final NodeTypeManagerImpl manager;
+    protected final Log log;
     protected Val name;
-    protected int onParentVersion;
+    protected int onParentVersion = OnParentVersionAction.IGNORE;
     protected boolean isAutoCreated;
     protected boolean isMandatory;
     protected boolean isProtected;
 
     ItemDefinitionImpl(NodeTypeManagerImpl manager) {
         this.manager = manager;
+        this.log = manager.getLog();
     }
 
     public NodeType getDeclaringNodeType() {
+        log.code(this, "getDeclaringNodeType");
         // TODO Auto-generated method stub
         return null;
     }
 
     public String getName() {
+        log.code(this, "getName");
         return manager.nameToString(name);
     }
 
     public int getOnParentVersion() {
+        log.code(this, "getOnParentVersion");
         return onParentVersion;
     }
 
     public boolean isAutoCreated() {
+        log.code(this, "isAutoCreated");
         return isAutoCreated;
     }
 
     public boolean isMandatory() {
+        log.code(this, "isMandatory");
         return isMandatory;
     }
 
     public boolean isProtected() {
+        log.code(this, "isProtected");
         return isProtected;
     }
 
+    public String toString() {
+        StringBuilder buff = new StringBuilder();
+        if (isAutoCreated) {
+            buff.append(" a");
+        }
+        if (isMandatory) {
+            buff.append(" m");
+        }
+        if (isProtected) {
+            buff.append(" p");
+        }
+        buff.append(' ').append(OnParentVersionAction.nameFromValue(onParentVersion));
+        return buff.toString();
+    }
+
 }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionImpl.java?rev=932957&r1=932956&r2=932957&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionImpl.java Sun Apr 11 17:50:41 2010
@@ -16,41 +16,86 @@
  */
 package org.apache.jackrabbit.j3.nodetype;
 
+import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.NodeType;
 
 /**
- * The node definition implementation.
+ * The implementation of the corresponding JCR interface.
  */
 public class NodeDefinitionImpl extends ItemDefinitionImpl implements NodeDefinition {
 
-    protected NodeType defaultPrimaryType;
+    protected String defaultPrimaryTypeName;
     protected boolean allowsSameNameSiblings;
+    protected String[] requiredPrimaryTypeNames;
+    protected NodeTypeImpl[] requiredPrimaryTypes;
 
     NodeDefinitionImpl(NodeTypeManagerImpl manager) {
         super(manager);
     }
 
+    void init() throws RepositoryException {
+        if (requiredPrimaryTypeNames == null) {
+            requiredPrimaryTypes = new NodeTypeImpl[0];
+            return;
+        }
+        requiredPrimaryTypes = new NodeTypeImpl[requiredPrimaryTypeNames.length];
+        for (int i = 0; i < requiredPrimaryTypeNames.length; i++) {
+            requiredPrimaryTypes[i] = manager.getNodeType(requiredPrimaryTypeNames[i]);
+        }
+    }
+
     public boolean allowsSameNameSiblings() {
+        log.code(this, "allowsSameNameSiblings");
         return allowsSameNameSiblings;
     }
 
     public NodeType getDefaultPrimaryType() {
-        return defaultPrimaryType;
+        log.code(this, "getDefaultPrimaryType");
+        try {
+            return manager.getNodeType(defaultPrimaryTypeName);
+        } catch (RepositoryException e) {
+            return null;
+        }
     }
 
     public String getDefaultPrimaryTypeName() {
-        return defaultPrimaryType == null ? null : defaultPrimaryType.getName();
+        log.code(this, "getDefaultPrimaryTypeName");
+        return defaultPrimaryTypeName;
     }
 
     public String[] getRequiredPrimaryTypeNames() {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "getRequiredPrimaryTypeNames");
+        return requiredPrimaryTypeNames;
     }
 
     public NodeType[] getRequiredPrimaryTypes() {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "getRequiredPrimaryTypes");
+        return requiredPrimaryTypes;
+    }
+
+    public String toString() {
+        StringBuilder buff = new StringBuilder();
+        buff.append('+').append(manager.nameToString(name));
+        if (requiredPrimaryTypeNames != null && requiredPrimaryTypeNames.length > 0) {
+            buff.append('(');
+            int i = 0;
+            for (String s : requiredPrimaryTypeNames) {
+                if (i++ > 0) {
+                    buff.append(',');
+                }
+                buff.append(s);
+            }
+            buff.append(')');
+        }
+        if (defaultPrimaryTypeName != null) {
+            buff.append('=').append(defaultPrimaryTypeName);
+        }
+        buff.append(super.toString());
+        if (allowsSameNameSiblings) {
+            buff.append(" sns");
+        }
+        return buff.toString();
     }
 
 }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionTemplateImpl.java?rev=932957&r1=932956&r2=932957&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionTemplateImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeDefinitionTemplateImpl.java Sun Apr 11 17:50:41 2010
@@ -16,12 +16,11 @@
  */
 package org.apache.jackrabbit.j3.nodetype;
 
-import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NodeDefinitionTemplate;
 
 /**
- * The node definition template implementation.
+ * The implementation of the corresponding JCR interface.
  */
 public class NodeDefinitionTemplateImpl extends NodeDefinitionImpl implements NodeDefinitionTemplate {
 
@@ -30,41 +29,43 @@ public class NodeDefinitionTemplateImpl 
     }
 
     public void setName(String name) throws ConstraintViolationException {
+        log.code(this, "setName", name);
         this.name = manager.parseName(name);
     }
 
     public void setAutoCreated(boolean autoCreated) {
+        log.code(this, "setAutoCreated", autoCreated);
         this.isAutoCreated = autoCreated;
     }
 
     public void setDefaultPrimaryTypeName(String name) throws ConstraintViolationException {
-        try {
-            this.defaultPrimaryType = manager.getNodeType(name);
-        } catch (RepositoryException e) {
-            throw new ConstraintViolationException(e);
-        }
+        log.code(this, "setDefaultPrimaryTypeName", name);
+        this.defaultPrimaryTypeName = name;
     }
 
     public void setMandatory(boolean mandatory) {
+        log.code(this, "setMandatory", mandatory);
         this.isMandatory = mandatory;
     }
 
     public void setOnParentVersion(int opv) {
+        log.code(this, "setOnParentVersion", opv);
         this.onParentVersion = opv;
     }
 
     public void setProtected(boolean protectedStatus) {
+        log.code(this, "setProtected", protectedStatus);
         this.isProtected = protectedStatus;
     }
 
     public void setRequiredPrimaryTypeNames(String[] names) throws ConstraintViolationException {
-        // TODO Auto-generated method stub
-
+        log.code(this, "setRequiredPrimaryTypeNames", (Object) names);
+        requiredPrimaryTypeNames = names;
     }
 
     public void setSameNameSiblings(boolean allowSameNameSiblings) {
+        log.code(this, "setSameNameSiblings", allowSameNameSiblings);
         this.allowsSameNameSiblings = allowSameNameSiblings;
     }
 
-
 }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeDefinitionImpl.java?rev=932957&r1=932956&r2=932957&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeDefinitionImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeDefinitionImpl.java Sun Apr 11 17:50:41 2010
@@ -16,65 +16,120 @@
  */
 package org.apache.jackrabbit.j3.nodetype;
 
-import javax.jcr.nodetype.NodeDefinition;
+import java.util.ArrayList;
 import javax.jcr.nodetype.NodeTypeDefinition;
-import javax.jcr.nodetype.PropertyDefinition;
 import org.apache.jackrabbit.j3.mc.Val;
+import org.apache.jackrabbit.j3.util.Log;
+import org.apache.jackrabbit.j3.util.LogObject;
 
 /**
- * The node type definition implementation.
+ * The implementation of the corresponding JCR interface.
  */
-public class NodeTypeDefinitionImpl implements NodeTypeDefinition {
+public class NodeTypeDefinitionImpl implements NodeTypeDefinition, LogObject {
 
     protected final NodeTypeManagerImpl manager;
+    protected final Log log;
     protected Val name;
     protected boolean hasOrderableChildNodes;
     protected boolean isAbstract;
     protected boolean isMixin;
     protected boolean isQueryable;
     protected Val primaryItemName;
+    protected Val[] declaredSupertypeNames = {};
+    protected ArrayList<NodeDefinitionImpl> childNodes = new ArrayList<NodeDefinitionImpl>();
+    protected ArrayList<PropertyDefinitionImpl> properties = new ArrayList<PropertyDefinitionImpl>();
 
     NodeTypeDefinitionImpl(NodeTypeManagerImpl manager) {
         this.manager = manager;
+        this.log = manager.getLog();
     }
 
     public String getName() {
+        log.code(this, "getName");
         return manager.nameToString(name);
     }
 
-    public NodeDefinition[] getDeclaredChildNodeDefinitions() {
-        // TODO Auto-generated method stub
-        return null;
+    public Val getNameVal() {
+        return name;
     }
 
-    public PropertyDefinition[] getDeclaredPropertyDefinitions() {
-        // TODO Auto-generated method stub
-        return null;
+    public NodeDefinitionImpl[] getDeclaredChildNodeDefinitions() {
+        log.code(this, "getDeclaredChildNodeDefinitions");
+        return childNodes.toArray(new NodeDefinitionImpl[childNodes.size()]);
+    }
+
+    public PropertyDefinitionImpl[] getDeclaredPropertyDefinitions() {
+        log.code(this, "getDeclaredPropertyDefinitions");
+        return properties.toArray(new PropertyDefinitionImpl[properties.size()]);
     }
 
     public String[] getDeclaredSupertypeNames() {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "getDeclaredSupertypeNames");
+        String[] list = new String[declaredSupertypeNames.length];
+        for (int i = 0; i < list.length; i++) {
+            list[i] = manager.nameToString(declaredSupertypeNames[i]);
+        }
+        return list;
     }
 
     public String getPrimaryItemName() {
+        log.code(this, "getPrimaryItemName");
         return manager.nameToString(primaryItemName);
     }
 
     public boolean hasOrderableChildNodes() {
+        log.code(this, "hasOrderableChildNodes");
         return hasOrderableChildNodes;
     }
 
     public boolean isAbstract() {
+        log.code(this, "isAbstract");
         return isAbstract;
     }
 
     public boolean isMixin() {
+        log.code(this, "isMixin");
         return isMixin;
     }
 
     public boolean isQueryable() {
+        log.code(this, "isQueryable");
         return isQueryable;
     }
 
+    public String toString() {
+        StringBuilder buff = new StringBuilder();
+        buff.append('[').append(getName()).append(']');
+        if (declaredSupertypeNames != null && declaredSupertypeNames.length > 0) {
+            buff.append('>');
+            int i = 0;
+            for (String s : getDeclaredSupertypeNames()) {
+                if (i++ > 0) {
+                    buff.append(',');
+                }
+                buff.append(s);
+            }
+        }
+        if (hasOrderableChildNodes) {
+            buff.append(" o");
+        }
+        if (isMixin) {
+            buff.append(" m");
+        }
+        if (isAbstract) {
+            buff.append(" a");
+        }
+        buff.append(isQueryable ? " q" : " nq");
+        if (primaryItemName != null) {
+            buff.append('!').append(getPrimaryItemName());
+        }
+        for (PropertyDefinitionImpl p : properties) {
+            buff.append(p);
+        }
+        for (NodeDefinitionImpl c : childNodes) {
+            buff.append(c);
+        }
+        return buff.toString();
+    }
+
 }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeImpl.java?rev=932957&r1=932956&r2=932957&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeImpl.java Sun Apr 11 17:50:41 2010
@@ -16,90 +16,244 @@
  */
 package org.apache.jackrabbit.j3.nodetype;
 
+import java.util.ArrayList;
+import java.util.HashSet;
+import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeIterator;
 import javax.jcr.nodetype.PropertyDefinition;
+import org.apache.jackrabbit.j3.NodeImpl;
+import org.apache.jackrabbit.j3.mc.Val;
 
 /**
- * The node type implementation.
+ * The implementation of the corresponding JCR interface.
  */
 public class NodeTypeImpl extends NodeTypeDefinitionImpl implements NodeType {
 
-    NodeTypeImpl(NodeTypeManagerImpl manager) {
+    private final NodeTypeImpl[] declaredSupertypes;
+
+    NodeTypeImpl(NodeTypeManagerImpl manager, NodeTypeDefinitionImpl ntd) {
         super(manager);
+        this.childNodes = ntd.childNodes;
+        this.declaredSupertypeNames = ntd.declaredSupertypeNames;
+        this.hasOrderableChildNodes = ntd.hasOrderableChildNodes;
+        this.isAbstract = ntd.isAbstract;
+        this.isMixin = ntd.isMixin;
+        this.isQueryable = ntd.isQueryable;
+        this.name = ntd.name;
+        this.primaryItemName = ntd.primaryItemName;
+        this.properties = ntd.properties;
+        declaredSupertypes = new NodeTypeImpl[declaredSupertypeNames.length];
+    }
+
+    void init() throws RepositoryException {
+        for (NodeDefinitionImpl n : childNodes) {
+            n.init();
+        }
+        for (int i = 0; i < declaredSupertypes.length; i++) {
+            declaredSupertypes[i] = this.manager.getNodeType(declaredSupertypeNames[i]);
+        }
     }
 
     public boolean canAddChildNode(String childNodeName) {
-        // TODO Auto-generated method stub
-        return false;
+        log.code(this, "canAddChildNode", childNodeName);
+        return canAddChildNode(manager.parseName(childNodeName), null);
     }
 
     public boolean canAddChildNode(String childNodeName, String nodeTypeName) {
-        // TODO Auto-generated method stub
+        log.code(this, "canAddChildNode", childNodeName, nodeTypeName);
+        return canAddChildNode(manager.parseName(childNodeName), manager.parseName(nodeTypeName));
+    }
+
+    private boolean canAddChildNode(Val childNodeName, Val nodeTypeName) {
+        for (NodeDefinitionImpl n : childNodes) {
+            if (n.name.equals(childNodeName)) {
+                if (nodeTypeName == null) {
+                    return true;
+                }
+                for (NodeTypeImpl nt : n.requiredPrimaryTypes) {
+                    if (nt.isNodeType(nodeTypeName)) {
+                        return true;
+                    }
+                }
+            }
+        }
+        for (Val v : declaredSupertypeNames) {
+            if (manager.getNodeType(v).canAddChildNode(childNodeName, nodeTypeName)) {
+                return true;
+            }
+        }
         return false;
     }
 
     public boolean canRemoveItem(String itemName) {
-        // TODO Auto-generated method stub
-        return false;
+        log.code(this, "canRemoveItem", itemName);
+        return canRemoveNode(itemName) && canRemoveProperty(itemName);
     }
 
     public boolean canRemoveNode(String nodeName) {
-        // TODO Auto-generated method stub
+        log.code(this, "canRemoveNode", nodeName);
+        return canRemoveNode(manager.parseName(nodeName));
+    }
+
+    private boolean canRemoveNode(Val childNodeName) {
+        for (NodeDefinitionImpl n : childNodes) {
+            if (n.isMandatory && n.name.equals(childNodeName)) {
+                return false;
+            }
+        }
+        for (Val v : declaredSupertypeNames) {
+            if (manager.getNodeType(v).canRemoveNode(childNodeName)) {
+                return true;
+            }
+        }
         return false;
     }
 
     public boolean canRemoveProperty(String propertyName) {
-        // TODO Auto-generated method stub
-        return false;
+        log.code(this, "canRemoveProperty", propertyName);
+        return canRemoveProperty(manager.parseName(propertyName));
+    }
+
+    private boolean canRemoveProperty(Val propertyName) {
+        for (PropertyDefinitionImpl p : properties) {
+            if (p.name.equals(propertyName)) {
+                if (p.isMandatory) {
+                    return false;
+                }
+                // TODO p.valueConstraints
+            }
+        }
+        for (Val v : declaredSupertypeNames) {
+            if (!manager.getNodeType(v).canRemoveProperty(propertyName)) {
+                return false;
+            }
+        }
+        return true;
     }
 
     public boolean canSetProperty(String propertyName, Value value) {
-        // TODO Auto-generated method stub
-        return false;
+        log.code(this, "canSetProperty", propertyName, value);
+        return canSetProperty(manager.parseName(propertyName), value);
+    }
+
+    private boolean canSetProperty(Val propertyName, Value value) {
+        for (PropertyDefinitionImpl p : properties) {
+            if (p.name.equals(propertyName)) {
+                if (p.isMultiple) {
+                    return false;
+                }
+                // TODO p.valueConstraints
+            }
+        }
+        for (Val v : declaredSupertypeNames) {
+            if (!manager.getNodeType(v).canSetProperty(propertyName, value)) {
+                return false;
+            }
+        }
+        return true;
     }
 
     public boolean canSetProperty(String propertyName, Value[] values) {
-        // TODO Auto-generated method stub
-        return false;
+        log.code(this, "canSetProperty", propertyName, values);
+        return canSetProperty(manager.parseName(propertyName), values);
+    }
+
+    private boolean canSetProperty(Val propertyName, Value[] values) {
+        for (PropertyDefinitionImpl p : properties) {
+            if (p.name.equals(propertyName)) {
+                if (!p.isMultiple) {
+                    return false;
+                }
+                // TODO p.valueConstraints
+            }
+        }
+        for (Val v : declaredSupertypeNames) {
+            if (!manager.getNodeType(v).canSetProperty(propertyName, values)) {
+                return false;
+            }
+        }
+        return true;
     }
 
     public NodeDefinition[] getChildNodeDefinitions() {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "getChildNodeDefinitions");
+        return childNodes.toArray(new NodeDefinition[childNodes.size()]);
     }
 
     public NodeTypeIterator getDeclaredSubtypes() {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "getDeclaredSubtypes");
+        ArrayList<NodeTypeImpl> list = new ArrayList<NodeTypeImpl>();
+        for (NodeTypeImpl n : manager.getNodeTypeRegistry().getNodeTypes(true, true)) {
+            if (n.isNodeType(name)) {
+                list.add(n);
+            }
+        }
+        return new NodeTypeIteratorImpl(list, log);
     }
 
     public NodeType[] getDeclaredSupertypes() {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "getDeclaredSupertypes");
+        NodeType[] list = new NodeType[declaredSupertypeNames.length];
+        for (int i = 0; i < list.length; i++) {
+            list[i] = manager.getNodeType(declaredSupertypeNames[i]);
+        }
+        return list;
     }
 
     public PropertyDefinition[] getPropertyDefinitions() {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "getPropertyDefinitions");
+        return properties.toArray(new PropertyDefinition[properties.size()]);
     }
 
     public NodeTypeIterator getSubtypes() {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "getSubtypes");
+        HashSet<NodeTypeImpl> set = new HashSet<NodeTypeImpl>();
+        addSupertypes(set);
+        return new NodeTypeIteratorImpl(set, log);
     }
 
     public NodeType[] getSupertypes() {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "getSupertypes");
+        HashSet<NodeTypeImpl> set = new HashSet<NodeTypeImpl>();
+        addSupertypes(set);
+        return set.toArray(new NodeType[set.size()]);
+    }
+
+    void addSupertypes(HashSet<NodeTypeImpl> set) {
+        for (Val s : declaredSupertypeNames) {
+            NodeTypeImpl n = manager.getNodeType(s);
+            set.add(n);
+            n.addSupertypes(set);
+        }
     }
 
     public boolean isNodeType(String nodeTypeName) {
-        // TODO Auto-generated method stub
+        log.code(this, "isNodeType", nodeTypeName);
+        return isNodeType(manager.parseName(nodeTypeName));
+    }
+
+    private boolean isNodeType(Val n) {
+        if (n.equals(name)) {
+            return true;
+        }
+        for (Val d : declaredSupertypeNames) {
+            if (manager.getNodeType(d).isNodeType(n)) {
+                return true;
+            }
+        }
         return false;
     }
 
+    public void visit(NodeImpl node) throws RepositoryException {
+        for (PropertyDefinitionImpl p : properties) {
+            node.apply(p);
+        }
+        for (NodeTypeImpl s : declaredSupertypes) {
+            s.visit(node);
+        }
+    }
 
 }

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeIteratorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeIteratorImpl.java?rev=932957&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeIteratorImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeIteratorImpl.java Sun Apr 11 17:50:41 2010
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.j3.nodetype;
+
+import java.util.Collection;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeIterator;
+import org.apache.jackrabbit.j3.RangeIteratorImpl;
+import org.apache.jackrabbit.j3.util.Log;
+
+/**
+ * The implementation of the corresponding JCR interface.
+ */
+class NodeTypeIteratorImpl extends RangeIteratorImpl<NodeTypeImpl> implements NodeTypeIterator {
+
+    NodeTypeIteratorImpl(Collection<NodeTypeImpl> coll, Log log) {
+        super(coll.iterator(), coll.size(), log);
+    }
+
+    public NodeType nextNodeType() {
+        log.code(this, "nextNodeType");
+        return goNext();
+    }
+
+}
\ No newline at end of file

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeManagerImpl.java?rev=932957&r1=932956&r2=932957&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeManagerImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeManagerImpl.java Sun Apr 11 17:50:41 2010
@@ -16,203 +16,145 @@
  */
 package org.apache.jackrabbit.j3.nodetype;
 
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
+import java.util.ArrayList;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.NodeDefinitionTemplate;
-import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeDefinition;
 import javax.jcr.nodetype.NodeTypeExistsException;
 import javax.jcr.nodetype.NodeTypeIterator;
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.NodeTypeTemplate;
 import javax.jcr.nodetype.PropertyDefinitionTemplate;
-import org.apache.jackrabbit.j3.SessionImpl;
+import org.apache.jackrabbit.j3.NamespaceRegistryImpl;
 import org.apache.jackrabbit.j3.mc.Val;
+import org.apache.jackrabbit.j3.util.Log;
+import org.apache.jackrabbit.j3.util.LogObject;
 
 /**
- * A node type manager implementation.
+ * The implementation of the corresponding JCR interface.
  */
-public class NodeTypeManagerImpl implements NodeTypeManager {
+public class NodeTypeManagerImpl implements NodeTypeManager, LogObject {
 
-    private final HashMap<Val, NodeTypeImpl> nodeTypes = new HashMap<Val, NodeTypeImpl>();
-    private final SessionImpl session;
-
-    void initSystemNodeTypes() {
-        String[] name = {
-                "nt:base",
-                "nt:hierarchyNode",
-                "nt:file",
-                "nt:linkedFile",
-                "nt:folder",
-                "nt:resource",
-                "mix:title",
-                "mix:created",
-                "mix:lastModified",
-                "mix:language",
-                "mix:mimeType",
-                "nt:address",
-                "mix:etag",
-                "nt:unstructured",
-                "nt:nodeType",
-                "nt:propertyDefinition",
-                "nt:childNodeDefinition",
-                "mix:referenceable",
-                "mix:lockable",
-                "mix:shareable",
-                "mix:lifecycle",
-                "mix:simpleVersionable",
-                "mix:versionable",
-                "nt:version",
-                "nt:versionHistory",
-                "nt:frozenNode",
-                "nt:versionLabels",
-                "nt:versionedChild"
-        };
-        for (String n : name) {
-            NodeTypeImpl nt = new NodeTypeImpl(this);
-            nt.name = parseName(n);
-            nodeTypes.put(nt.name, nt);
-        }
-    }
-
-    public NodeTypeManagerImpl(SessionImpl session) {
-        this.session = session;
-        initSystemNodeTypes();
+    private final NamespaceRegistryImpl nsReg;
+    private final NodeTypeRegistry ntReg;
+    private final Log log;
+
+    public NodeTypeManagerImpl(NamespaceRegistryImpl nsReg, NodeTypeRegistry ntReg) {
+        this.log = nsReg.getLog();
+        this.nsReg = nsReg;
+        this.ntReg = ntReg;
     }
 
     String nameToString(Val name) {
-        return session.nameToString(name);
+        return nsReg.nameToString(name);
     }
 
     Val parseName(String name) {
-        return session.parseName(name);
+        return nsReg.parseName(name);
     }
 
-    public NodeType getNodeType(Val nodeTypeName) {
-        return nodeTypes.get(nodeTypeName);
+    public NodeTypeImpl getNodeType(Val nodeTypeName) {
+        return ntReg.getNodeType(nodeTypeName);
     }
 
-    public NodeType getNodeType(String nodeTypeName) throws NoSuchNodeTypeException, RepositoryException {
+    public NodeTypeImpl getNodeType(String nodeTypeName) throws NoSuchNodeTypeException, RepositoryException {
+        log.code(this, "getNodeType", nodeTypeName);
         return getNodeType(parseName(nodeTypeName));
     }
 
     public NodeDefinitionTemplate createNodeDefinitionTemplate() throws UnsupportedRepositoryOperationException,
             RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "createNodeDefinitionTemplate");
+        return new NodeDefinitionTemplateImpl(this);
     }
 
     public NodeTypeTemplate createNodeTypeTemplate() throws UnsupportedRepositoryOperationException,
             RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "createNodeTypeTemplate");
+        return new NodeTypeTemplateImpl(this);
     }
 
     public NodeTypeTemplate createNodeTypeTemplate(NodeTypeDefinition ntd)
             throws UnsupportedRepositoryOperationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "createNodeTypeTemplate", ntd);
+        return new NodeTypeTemplateImpl(this);
     }
 
     public PropertyDefinitionTemplate createPropertyDefinitionTemplate()
             throws UnsupportedRepositoryOperationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "createPropertyDefinitionTemplate");
+        return new PropertyDefinitionTemplateImpl(this);
     }
 
     public NodeTypeIterator getAllNodeTypes() throws RepositoryException {
-        return new NodeTypeIteratorImpl(nodeTypes.values());
+        log.code(this, "getAllNodeTypes");
+        return new NodeTypeIteratorImpl(ntReg.getNodeTypes(true, true), log);
     }
 
     public NodeTypeIterator getMixinNodeTypes() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "getMixinNodeTypes");
+        return new NodeTypeIteratorImpl(ntReg.getNodeTypes(false, true), log);
     }
 
     public NodeTypeIterator getPrimaryNodeTypes() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "getPrimaryNodeTypes");
+        return new NodeTypeIteratorImpl(ntReg.getNodeTypes(true, false), log);
     }
 
     public boolean hasNodeType(String name) throws RepositoryException {
-        // TODO Auto-generated method stub
-        return false;
+        log.code(this, "hasNodeType", name);
+        return ntReg.getNodeType(parseName(name)) != null;
     }
 
-    public NodeType registerNodeType(NodeTypeDefinition ntd, boolean allowUpdate)
+    public NodeTypeImpl registerNodeType(NodeTypeDefinition ntd, boolean allowUpdate)
             throws InvalidNodeTypeDefinitionException, NodeTypeExistsException,
             UnsupportedRepositoryOperationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "registerNodeType", ntd, allowUpdate);
+        NodeTypeImpl nt = new NodeTypeImpl(this, (NodeTypeDefinitionImpl) ntd);
+        nt.init();
+        ntReg.register(parseName(nt.getName()), nt);
+        return nt;
     }
 
     public NodeTypeIterator registerNodeTypes(NodeTypeDefinition[] ntds, boolean allowUpdate)
             throws InvalidNodeTypeDefinitionException, NodeTypeExistsException,
             UnsupportedRepositoryOperationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "registerNodeTypes", ntds, allowUpdate);
+        // TODO check conflicts
+        ArrayList<NodeTypeImpl> list = new ArrayList<NodeTypeImpl>();
+        for (NodeTypeDefinition def : ntds) {
+            list.add(registerNodeType(def, allowUpdate));
+        }
+        return new NodeTypeIteratorImpl(list, log);
     }
 
     public void unregisterNodeType(String name) throws UnsupportedRepositoryOperationException,
             NoSuchNodeTypeException, RepositoryException {
-        // TODO Auto-generated method stub
-
+        log.code(this, "unregisterNodeType", name);
+        ntReg.unregisterNodeType(parseName(name));
     }
 
     public void unregisterNodeTypes(String[] names) throws UnsupportedRepositoryOperationException,
             NoSuchNodeTypeException, RepositoryException {
-        // TODO Auto-generated method stub
-
-    }
-
-    /**
-     * The node type iterator implementation.
-     */
-    class NodeTypeIteratorImpl implements NodeTypeIterator {
-
-        private final Iterator<NodeTypeImpl> iterator;
-        private int pos;
-
-        NodeTypeIteratorImpl(Collection<NodeTypeImpl> coll) {
-            this.iterator = coll.iterator();
-        }
-
-        public NodeType nextNodeType() {
-            pos++;
-            return iterator.next();
-        }
-
-        public long getPosition() {
-            return pos;
-        }
-
-        public long getSize() {
-            return nodeTypes.size();
-        }
-
-        public void skip(long skipNum) {
-            for (long i = 0; i < skipNum; i++) {
-                next();
-            }
-        }
-
-        public boolean hasNext() {
-            return iterator.hasNext();
+        log.code(this, "unregisterNodeTypes", (Object) names);
+        for (String n : names) {
+            unregisterNodeType(n);
         }
+    }
 
-        public Object next() {
-            return nextNodeType();
-        }
+    public String toString() {
+        return ntReg.toString();
+    }
 
-        public void remove() {
-            iterator.remove();
-        }
+    NodeTypeRegistry getNodeTypeRegistry() {
+        return ntReg;
+    }
 
+    Log getLog() {
+        return log;
     }
 
 }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeRegistry.java?rev=932957&r1=932956&r2=932957&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeRegistry.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeRegistry.java Sun Apr 11 17:50:41 2010
@@ -16,9 +16,99 @@
  */
 package org.apache.jackrabbit.j3.nodetype;
 
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeTemplate;
+import org.apache.jackrabbit.j3.NamespaceRegistryImpl;
+import org.apache.jackrabbit.j3.ValueFactoryImpl;
+import org.apache.jackrabbit.j3.mc.Val;
+import org.apache.jackrabbit.j3.util.ExceptionFactory;
+import org.apache.jackrabbit.j3.util.Log;
+
 /**
  * The node type registry.
  */
 public class NodeTypeRegistry {
 
+    private static final String BUILT_IN_CND = "[nt:base] a nq-jcr:primaryType(Name) a m p COMPUTE-jcr:mixinTypes(Name) p COMPUTE*[nt:hierarchyNode]>mix:created a nq[nt:file]>nt:hierarchyNode nq!jcr:content+jcr:content(nt:base) m IGNORE[nt:linkedFile]>nt:hierarchyNode nq!jcr:content-jcr:content(Reference) m IGNORE[nt:folder]>nt:hierarchyNode nq+*(nt:hierarchyNode) VERSION[nt:resource]>mix:mimeType,mix:lastModified,mix:referenceable nq!jcr:data-jcr:data(Binary) m IGNORE[mix:title] m nq-jcr:title(String) IGNORE-jcr:description(String) IGNORE[mix:created] m nq-jcr:created(Date) a p IGNORE-jcr:createdBy(String) a p IGNORE[mix:lastModified] m nq-jcr:lastModified(Date) a IGNORE-jcr:lastModifiedBy(String) a IGNORE[mix:language] m nq-jcr:language(String) IGNORE[mix:mimeType] m nq-jcr:mimeType(String) IGNORE-jcr:encoding(String) IGNORE[nt:address] nq-jcr:protocol(String) IGNORE-jcr:host(String) IGNORE-jcr:port(String) IGNORE-jcr:repository(String) IGNORE-jcr:workspace(String) IGNORE-
 jcr:path(Path) IGNORE-jcr:id(WeakReference) IGNORE[mix:etag] m nq-jcr:etag(String) a p IGNORE[nt:unstructured] o nq-*(undefined) IGNORE*-*(undefined) IGNORE+*(nt:base)=nt:unstructured VERSION sns[mix:referenceable] m nq-jcr:uuid(String) a m p INITIALIZE[mix:lockable] m nq-jcr:lockOwner(String) p IGNORE-jcr:lockIsDeep(Boolean) p IGNORE[mix:shareable]>mix:referenceable m nq[mix:simpleVersionable] m nq-jcr:isCheckedOut(Boolean)='true' a m p IGNORE[mix:versionable]>mix:simpleVersionable,mix:referenceable m nq-jcr:versionHistory(Reference) m p IGNORE<'nt:versionHistory'-jcr:baseVersion(Reference) m p IGNORE<'nt:version'-jcr:predecessors(Reference) m p IGNORE*<'nt:version'-jcr:mergeFailed(Reference) p ABORT*<'nt:version'-jcr:activity(Reference) p IGNORE<'nt:activity'-jcr:configuration(Reference) p IGNORE<'nt:configuration'[nt:versionHistory]>mix:referenceable nq-jcr:versionableUuid(String) a m p ABORT-jcr:copiedFrom(WeakReference) p ABORT<'nt:version'+jcr:rootVersion(nt:version)=n
 t:version a m p ABORT+jcr:versionLabels(nt:versionLabels)=nt:versionLabels a m p ABORT+*(nt:version)=nt:version p ABORT[nt:versionLabels] nq-*(Reference) p ABORT<'nt:version'[nt:version]>mix:referenceable nq-jcr:created(Date) a m p ABORT-jcr:predecessors(Reference) p ABORT*<'nt:version'-jcr:successors(Reference) p ABORT*<'nt:version'-jcr:activity(Reference) p ABORT<'nt:activity'+jcr:frozenNode(nt:frozenNode) p ABORT[nt:frozenNode]>mix:referenceable o nq-jcr:frozenPrimaryType(Name) a m p ABORT-jcr:frozenMixinTypes(Name) p ABORT*-jcr:frozenUuid(String) a m p ABORT-*(undefined) p ABORT-*(undefined) p ABORT*+*(nt:base) p ABORT sns[nt:versionedChild] nq-jcr:childVersionHistory(Reference) a m p ABORT<'nt:versionHistory'[nt:activity]>mix:referenceable nq-jcr:activityTitle(String) a m p IGNORE[nt:configuration]>mix:versionable nq-jcr:root(Reference) a m p IGNORE[nt:nodeType] nq-jcr:nodeTypeName(Name) m p IGNORE-jcr:supertypes(Name) p IGNORE*-jcr:isAbstract(Boolean) m p IGNORE-jcr:is
 Queryable(Boolean) m p IGNORE-jcr:isMixin(Boolean) m p IGNORE-jcr:hasOrderableChildNodes(Boolean) m p IGNORE-jcr:primaryItemName(Name) p IGNORE+jcr:propertyDefinition(nt:propertyDefinition)=nt:propertyDefinition p IGNORE sns+jcr:childNodeDefinition(nt:childNodeDefinition)=nt:childNodeDefinition p IGNORE sns[nt:propertyDefinition] nq-jcr:name(Name) p IGNORE-jcr:autoCreated(Boolean) m p IGNORE-jcr:mandatory(Boolean) m p IGNORE-jcr:onParentVersion(String) m p IGNORE<'COPY','VERSION','INITIALIZE','COMPUTE','IGNORE','ABORT'-jcr:protected(Boolean) m p IGNORE-jcr:requiredType(String) m p IGNORE<'STRING','URI','BINARY','LONG','DOUBLE','DECIMAL','BOOLEAN','DATE','NAME','PATH','REFERENCE','WEAKREFERENCE','UNDEFINED'-jcr:valueConstraints(String) p IGNORE*-jcr:defaultValues(undefined) p IGNORE*-jcr:multiple(Boolean) m p IGNORE-jcr:availableQueryOperators(Name) m p IGNORE*-jcr:isFullTextSearchable(Boolean) m p IGNORE-jcr:isQueryOrderable(Boolean) m p IGNORE[nt:childNodeDefinition] nq-jcr
 :name(Name) p IGNORE-jcr:autoCreated(Boolean) m p IGNORE-jcr:mandatory(Boolean) m p IGNORE-jcr:onParentVersion(String) m p IGNORE<'COPY','VERSION','INITIALIZE','COMPUTE','IGNORE','ABORT'-jcr:protected(Boolean) m p IGNORE-jcr:requiredPrimaryTypes(Name)='nt:base' m p IGNORE*-jcr:defaultPrimaryType(Name) p IGNORE-jcr:sameNameSiblings(Boolean) m p IGNORE[nt:query] nq-jcr:statement(String) IGNORE-jcr:language(String) IGNORE[mix:lifecycle] m nq-jcr:lifecyclePolicy(Reference) p INITIALIZE-jcr:currentLifecycleState(String) p INITIALIZE[rep:root]>nt:unstructured nq+jcr:system(rep:system)=rep:system m IGNORE[rep:system] o nq+jcr:versionStorage(rep:versionStorage)=rep:versionStorage m p ABORT+jcr:nodeTypes(rep:nodeTypes)=rep:nodeTypes m p ABORT+jcr:activities(rep:Activities)=rep:Activities m p ABORT+jcr:configurations(rep:Configurations)=rep:Configurations p ABORT+*(nt:base)=nt:base IGNORE[rep:nodeTypes] nq+*(nt:nodeType)=nt:nodeType p ABORT[rep:versionStorage] nq+*(nt:versionHistory)=
 nt:versionHistory p ABORT+*(rep:versionStorage)=rep:versionStorage p ABORT[rep:Activities] nq+*(nt:activity)=nt:activity p ABORT+*(rep:Activities)=rep:Activities p ABORT[rep:Configurations] nq+*(nt:configuration)=nt:configuration ABORT+*(rep:Configurations)=rep:Configurations ABORT[rep:VersionReference] m nq-rep:versions(Reference) p IGNORE*[rep:AccessControllable] m nq+rep:policy(rep:Policy) p IGNORE[rep:Policy] a nq[rep:ACL]>rep:Policy o nq+*(rep:ACE)=rep:GrantACE p IGNORE[rep:ACE] nq-rep:principalName(String) m p IGNORE-rep:privileges(Name) m p IGNORE*-rep:nodePath(Path) p IGNORE-rep:glob(String) p IGNORE-*(undefined) p IGNORE[rep:GrantACE]>rep:ACE nq[rep:DenyACE]>rep:ACE nq[rep:AccessControl] nq+*(rep:AccessControl) p IGNORE+*(rep:PrincipalAccessControl) p IGNORE[rep:PrincipalAccessControl]>rep:AccessControl nq+rep:policy(rep:Policy) p IGNORE[rep:Authorizable]>mix:referenceable,nt:hierarchyNode a nq-rep:principalName(String) m p IGNORE-*(undefined) IGNORE-*(undefined) IG
 NORE*+*(nt:base)=nt:unstructured VERSION[rep:Impersonatable] m nq-rep:impersonators(String) p IGNORE*[rep:User]>rep:Authorizable,rep:Impersonatable nq-rep:password(String) m p IGNORE[rep:Group]>rep:Authorizable nq-rep:members(WeakReference) p IGNORE*<'rep:Authorizable'[rep:AuthorizableFolder]>nt:hierarchyNode nq+*(rep:Authorizable)=rep:User VERSION+*(rep:AuthorizableFolder)=rep:AuthorizableFolder VERSION[rep:RetentionManageable] m nq-rep:hold(undefined) p IGNORE*-rep:retentionPolicy(undefined) p IGNORE";
+    private static final LinkedHashMap<Val, NodeTypeImpl> BUILT_IN_NODE_TYPES;
+    private final LinkedHashMap<Val, NodeTypeImpl> customNodeTypes = new LinkedHashMap<Val, NodeTypeImpl>();
+
+    static {
+        BUILT_IN_NODE_TYPES = new LinkedHashMap<Val, NodeTypeImpl>();
+        try {
+            Log log = Log.DEFAULT;
+            NamespaceRegistryImpl nsReg = NamespaceRegistryImpl.BUILT_IN;
+            NodeTypeRegistry ntReg = new NodeTypeRegistry();
+            ValueFactoryImpl vf = new ValueFactoryImpl(null, nsReg, log);
+            NodeTypeManagerImpl ntm = new NodeTypeManagerImpl(nsReg, ntReg);
+            CndParser parser = new CndParser(ntm, nsReg, vf, BUILT_IN_CND);
+            parser.parse();
+            for (NodeTypeTemplate nt : parser.getNodeTypeTemplates()) {
+                NodeTypeImpl n = new NodeTypeImpl(ntm, (NodeTypeDefinitionImpl) nt);
+                BUILT_IN_NODE_TYPES.put(n.getNameVal(), n);
+            }
+            for (NodeTypeImpl nt : BUILT_IN_NODE_TYPES.values()) {
+                nt.init();
+            }
+        } catch (Exception e) {
+            throw ExceptionFactory.runtime(e);
+        }
+    }
+
+    public LinkedHashMap<Val, NodeTypeImpl> getNodeTypes() {
+        return customNodeTypes;
+    }
+
+    List<NodeTypeImpl> getNodeTypes(boolean primary, boolean mixin) {
+        ArrayList<NodeTypeImpl> list = new ArrayList<NodeTypeImpl>();
+        for (NodeTypeImpl nt : BUILT_IN_NODE_TYPES.values()) {
+            if ((mixin == nt.isMixin) || (primary == !nt.isMixin)) {
+                list.add(nt);
+            }
+        }
+        for (NodeTypeImpl nt : customNodeTypes.values()) {
+            if ((mixin == nt.isMixin) || (primary == !nt.isMixin)) {
+                list.add(nt);
+            }
+        }
+        return list;
+    }
+
+    public NodeTypeImpl getNodeType(Val nodeTypeName) {
+        NodeTypeImpl nt = BUILT_IN_NODE_TYPES.get(nodeTypeName);
+        if (nt == null) {
+            nt = customNodeTypes.get(nodeTypeName);
+        }
+        return nt;
+    }
+
+    public void unregisterNodeType(Val name) throws RepositoryException {
+        if (BUILT_IN_NODE_TYPES.containsKey(name)) {
+            throw ExceptionFactory.repository("Can't unregister built-in node type {0}", name);
+        }
+        customNodeTypes.remove(name);
+    }
+
+    public String toString() {
+        StringBuilder buff = new StringBuilder();
+        for (NodeType nt : BUILT_IN_NODE_TYPES.values()) {
+            buff.append(nt.toString());
+        }
+        for (NodeType nt : customNodeTypes.values()) {
+            buff.append(nt.toString());
+        }
+        return buff.toString();
+    }
+
+    public void register(Val name, NodeTypeImpl nt) throws RepositoryException {
+        if (BUILT_IN_NODE_TYPES.containsKey(name)) {
+            throw ExceptionFactory.repository("Can't re-register built-in node type {0}", name);
+        }
+        customNodeTypes.put(name, nt);
+    }
+
 }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeTemplateImpl.java?rev=932957&r1=932956&r2=932957&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeTemplateImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/NodeTypeTemplateImpl.java Sun Apr 11 17:50:41 2010
@@ -18,12 +18,11 @@ package org.apache.jackrabbit.j3.nodetyp
 
 import java.util.List;
 import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NodeDefinitionTemplate;
 import javax.jcr.nodetype.NodeTypeTemplate;
-import javax.jcr.nodetype.PropertyDefinitionTemplate;
+import org.apache.jackrabbit.j3.mc.Val;
 
 /**
- * The node type template implementation.
+ * The implementation of the corresponding JCR interface.
  */
 public class NodeTypeTemplateImpl extends NodeTypeDefinitionImpl implements NodeTypeTemplate {
 
@@ -32,41 +31,51 @@ public class NodeTypeTemplateImpl extend
     }
 
     public void setName(String name) throws ConstraintViolationException {
+        log.code(this, "setName", name);
         this.name = manager.parseName(name);
     }
 
-    public List<NodeDefinitionTemplate> getNodeDefinitionTemplates() {
-        // TODO Auto-generated method stub
-        return null;
+    public List<NodeDefinitionImpl> getNodeDefinitionTemplates() {
+        log.code(this, "getNodeDefinitionTemplates");
+        return childNodes;
     }
 
-    public List<PropertyDefinitionTemplate> getPropertyDefinitionTemplates() {
-        // TODO Auto-generated method stub
-        return null;
+    public List<PropertyDefinitionImpl> getPropertyDefinitionTemplates() {
+        log.code(this, "getPropertyDefinitionTemplates");
+        return properties;
     }
 
     public void setAbstract(boolean abstractStatus) {
+        log.code(this, "setAbstract", abstractStatus);
         this.isAbstract = abstractStatus;
     }
 
     public void setDeclaredSuperTypeNames(String[] names) throws ConstraintViolationException {
-        // TODO Auto-generated method stub
-
+        log.code(this, "setDeclaredSuperTypeNames", (Object) names);
+        Val[] list = new Val[names.length];
+        for (int i = 0; i < names.length; i++) {
+            list[i] = manager.parseName(names[i]);
+        }
+        declaredSupertypeNames = list;
     }
 
     public void setMixin(boolean mixin) {
+        log.code(this, "setMixin", mixin);
         this.isMixin = mixin;
     }
 
     public void setOrderableChildNodes(boolean orderable) {
+        log.code(this, "setOrderableChildNodes", orderable);
         this.hasOrderableChildNodes = orderable;
     }
 
     public void setPrimaryItemName(String name) throws ConstraintViolationException {
+        log.code(this, "setPrimaryItemName", name);
         this.primaryItemName = manager.parseName(name);
     }
 
     public void setQueryable(boolean queryable) {
+        log.code(this, "setQueryable", queryable);
         this.isQueryable = queryable;
     }
 

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionImpl.java?rev=932957&r1=932956&r2=932957&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionImpl.java Sun Apr 11 17:50:41 2010
@@ -16,11 +16,18 @@
  */
 package org.apache.jackrabbit.j3.nodetype;
 
+import java.util.Calendar;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.nodetype.PropertyDefinition;
+import org.apache.jackrabbit.j3.mc.Val;
+import org.apache.jackrabbit.j3.util.DateUtils;
+import org.apache.jackrabbit.j3.util.ExceptionFactory;
+import org.apache.jackrabbit.j3.util.StringUtils;
 
 /**
- * The property definition implementation.
+ * The implementation of the corresponding JCR interface.
  */
 public class PropertyDefinitionImpl extends ItemDefinitionImpl implements PropertyDefinition {
 
@@ -28,40 +35,134 @@ public class PropertyDefinitionImpl exte
     protected boolean isFullTextSearchable;
     protected boolean isMultiple;
     protected boolean isQueryOrderable;
+    protected String[] availableQueryOperators;
+    protected Value[] defaultValues;
+    protected String[] valueConstraints;
 
     PropertyDefinitionImpl(NodeTypeManagerImpl manager) {
         super(manager);
     }
 
     public String[] getAvailableQueryOperators() {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "getAvailableQueryOperators");
+        return availableQueryOperators;
     }
 
     public Value[] getDefaultValues() {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "getDefaultValues");
+        return defaultValues;
     }
 
     public int getRequiredType() {
+        log.code(this, "getRequiredType");
         return requiredType;
     }
 
     public String[] getValueConstraints() {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "getValueConstraints");
+        return valueConstraints;
     }
 
     public boolean isFullTextSearchable() {
+        log.code(this, "isFullTextSearchable");
         return isFullTextSearchable;
     }
 
     public boolean isMultiple() {
+        log.code(this, "isMultiple");
         return isMultiple;
     }
 
     public boolean isQueryOrderable() {
+        log.code(this, "isQueryOrderable");
         return isQueryOrderable;
     }
 
+    public String toString() {
+        StringBuilder buff = new StringBuilder();
+        buff.append("-").append(getName()).append("(").
+            append(PropertyType.nameFromValue(requiredType)).append(')');
+        if (defaultValues != null) {
+            buff.append('=');
+            int i = 0;
+            for (Value v : defaultValues) {
+                if (i++ > 0) {
+                    buff.append(',');
+                }
+                String s;
+                try {
+                    s = v.getString();
+                } catch (RepositoryException e) {
+                    s = e.toString();
+                }
+                buff.append('\'').append(StringUtils.javaEncode(s)).append('\'');
+            }
+        }
+        buff.append(super.toString());
+        if (isMultiple) {
+            buff.append("*");
+        }
+        if (availableQueryOperators != null) {
+            buff.append(" qop\'");
+            int i = 0;
+            for (String s : availableQueryOperators) {
+                if (i++ > 0) {
+                    buff.append(',');
+                }
+                buff.append(s);
+            }
+            buff.append('\'');
+        }
+        if (!isFullTextSearchable) {
+            buff.append(" nof");
+        }
+        if (!isQueryOrderable) {
+            buff.append(" nqord");
+        }
+        if (!isQueryOrderable) {
+            buff.append(" nqord");
+        }
+        if (valueConstraints != null) {
+            buff.append('<');
+            int i = 0;
+            for (String s : valueConstraints) {
+                if (i++ > 0) {
+                    buff.append(',');
+                }
+                buff.append("\'").append(StringUtils.javaEncode(s)).append("\'");
+            }
+        }
+        return buff.toString();
+    }
+
+    public Val getNameVal() {
+        return name;
+    }
+
+    public Val getDefaultVal() {
+        switch (requiredType) {
+        case PropertyType.BINARY:
+            return Val.get(new byte[0]);
+        case PropertyType.BOOLEAN:
+            return Val.FALSE;
+        case PropertyType.DATE:
+            return Val.get(PropertyType.DATE, DateUtils.convertCalendarToString(Calendar.getInstance()));
+        case PropertyType.DECIMAL:
+            return Val.get(PropertyType.DECIMAL, "0");
+        case PropertyType.DOUBLE:
+            return Val.get(PropertyType.DOUBLE, "0");
+        case PropertyType.LONG:
+            return Val.get(0);
+        case PropertyType.NAME:
+        case PropertyType.PATH:
+        case PropertyType.REFERENCE:
+        case PropertyType.STRING:
+        case PropertyType.URI:
+        case PropertyType.WEAKREFERENCE:
+            // TODO what is the default value auto-created properties
+            return Val.get(requiredType, "");
+        }
+        throw ExceptionFactory.illegalArgument("type: " + requiredType);
+    }
+
 }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionTemplateImpl.java?rev=932957&r1=932956&r2=932957&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionTemplateImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/nodetype/PropertyDefinitionTemplateImpl.java Sun Apr 11 17:50:41 2010
@@ -21,7 +21,7 @@ import javax.jcr.nodetype.ConstraintViol
 import javax.jcr.nodetype.PropertyDefinitionTemplate;
 
 /**
- * The property definition template implementation.
+ * The implementation of the corresponding JCR interface.
  */
 public class PropertyDefinitionTemplateImpl extends PropertyDefinitionImpl implements PropertyDefinitionTemplate {
 
@@ -30,54 +30,64 @@ public class PropertyDefinitionTemplateI
     }
 
     public void setName(String name) throws ConstraintViolationException {
+        log.code(this, "setName", name);
         this.name = manager.parseName(name);
     }
 
     public void setAutoCreated(boolean autoCreated) {
+        log.code(this, "setAutoCreated", autoCreated);
         this.isAutoCreated = autoCreated;
     }
 
     public void setAvailableQueryOperators(String[] operators) {
-        // TODO Auto-generated method stub
-
+        log.code(this, "setAvailableQueryOperators", (Object) operators);
+        // TODO validate
+        this.availableQueryOperators = operators;
     }
 
     public void setDefaultValues(Value[] defaultValues) {
-        // TODO Auto-generated method stub
-
+        log.code(this, "setDefaultValues", (Object) defaultValues);
+        this.defaultValues = defaultValues;
     }
 
     public void setFullTextSearchable(boolean fullTextSearchable) {
+        log.code(this, "setFullTextSearchable", fullTextSearchable);
         this.isFullTextSearchable = fullTextSearchable;
     }
 
     public void setMandatory(boolean mandatory) {
+        log.code(this, "setMandatory", mandatory);
         this.isMandatory = mandatory;
     }
 
     public void setMultiple(boolean multiple) {
+        log.code(this, "setMultiple", multiple);
         this.isMultiple = multiple;
     }
 
     public void setOnParentVersion(int opv) {
+        log.code(this, "setOnParentVersion", opv);
         this.onParentVersion = opv;
     }
 
     public void setProtected(boolean protectedStatus) {
+        log.code(this, "setProtected", protectedStatus);
         this.isProtected = protectedStatus;
     }
 
     public void setQueryOrderable(boolean queryOrderable) {
+        log.code(this, "setQueryOrderable", queryOrderable);
         this.isQueryOrderable = queryOrderable;
     }
 
     public void setRequiredType(int type) {
+        log.code(this, "setRequiredType", type);
         this.requiredType = type;
     }
 
     public void setValueConstraints(String[] constraints) {
-        // TODO Auto-generated method stub
-
+        log.code(this, "setValueConstraints", (Object) constraints);
+        this.valueConstraints = constraints;
     }
 
 }



Mime
View raw message