jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r827966 [15/15] - in /jackrabbit/sandbox/JCR-1456: ./ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security...
Date Wed, 21 Oct 2009 11:38:44 GMT
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java Wed Oct 21 11:38:31 2009
@@ -16,972 +16,25 @@
  */
 package org.apache.jackrabbit.spi.commons.query.sql2;
 
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
 import javax.jcr.ValueFactory;
-import javax.jcr.query.InvalidQueryException;
-import javax.jcr.query.qom.BindVariableValue;
-import javax.jcr.query.qom.Column;
-import javax.jcr.query.qom.Constraint;
-import javax.jcr.query.qom.DynamicOperand;
-import javax.jcr.query.qom.JoinCondition;
-import javax.jcr.query.qom.Literal;
-import javax.jcr.query.qom.Ordering;
-import javax.jcr.query.qom.PropertyExistence;
-import javax.jcr.query.qom.PropertyValue;
-import javax.jcr.query.qom.QueryObjectModel;
 import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Selector;
-import javax.jcr.query.qom.Source;
-import javax.jcr.query.qom.StaticOperand;
-
-import org.apache.jackrabbit.spi.commons.query.qom.JoinType;
-import org.apache.jackrabbit.spi.commons.query.qom.Operator;
 
 /**
  * The SQL2 parser can convert a JCR-SQL2 query to a QueryObjectModel.
+ *
+ * @deprecated use {@link org.apache.jackrabbit.commons.query.sql2.Parser}
+ *             instead.
  */
-public class Parser {
-
-    // Character types, used during the tokenizer phase
-    private static final int CHAR_END = -1, CHAR_VALUE = 2, CHAR_QUOTED = 3;
-    private static final int CHAR_NAME = 4, CHAR_SPECIAL_1 = 5, CHAR_SPECIAL_2 = 6;
-    private static final int CHAR_STRING = 7, CHAR_DECIMAL = 8;
-
-    // Token types
-    private static final int KEYWORD = 1, IDENTIFIER = 2, PARAMETER = 3, END = 4, VALUE = 5;
-    private static final int MINUS = 12, PLUS = 13, OPEN = 14, CLOSE = 15;
-
-    // The query as an array of characters and character types
-    private String statement;
-    private char[] statementChars;
-    private int[] characterTypes;
-
-    // The current state of the parser
-    private int parseIndex;
-    private int currentTokenType;
-    private String currentToken;
-    private boolean currentTokenQuoted;
-    private Value currentValue;
-    private ArrayList<String> expected;
+public class Parser extends org.apache.jackrabbit.commons.query.sql2.Parser {
 
-    // The bind variables
-    private HashMap<String, BindVariableValue> bindVariables;
-
-    // The list of selectors of this query
-    private ArrayList<Selector> selectors;
-
-    // SQL injection protection: if disabled, literals are not allowed
-    private boolean allowTextLiterals = true, allowNumberLiterals = true;
-
-    private QueryObjectModelFactory factory;
-    private ValueFactory valueFactory;
 
     /**
      * Create a new parser. A parser can be re-used, but it is not thread safe.
      *
-     * @param factory the query object model factory
+     * @param factory      the query object model factory
      * @param valueFactory the value factory
      */
     public Parser(QueryObjectModelFactory factory, ValueFactory valueFactory) {
-        this.factory = factory;
-        this.valueFactory = valueFactory;
-    }
-
-    /**
-     * Parse a JCR-SQL2 query and return the query object model
-     *
-     * @param query the query string
-     * @return the query object model
-     * @throws RepositoryException if parsing failed
-     */
-    public QueryObjectModel createQueryObjectModel(String query) throws RepositoryException {
-        initialize(query);
-        selectors = new ArrayList<Selector>();
-        expected = new ArrayList<String>();
-        bindVariables = new HashMap<String, BindVariableValue>();
-        read();
-        read("SELECT");
-        ArrayList<ColumnOrWildcard> list = parseColumns();
-        read("FROM");
-        Source source = parseSource();
-        Column[] columnArray = resolveColumns(list);
-        Constraint constraint = null;
-        if (readIf("WHERE")) {
-            constraint = parseConstraint();
-        }
-        Ordering[] orderings = null;
-        if (readIf("ORDER")) {
-            read("BY");
-            orderings = parseOrder();
-        }
-        if (currentToken.length() > 0) {
-            throw getSyntaxError("<end>");
-        }
-        return factory.createQuery(source, constraint, orderings, columnArray);
-    }
-
-    private Selector parseSelector() throws RepositoryException {
-        String nodeTypeName = readName();
-        if (readIf("AS")) {
-            String selectorName = readName();
-            return factory.selector(nodeTypeName, selectorName);
-        } else {
-            return factory.selector(nodeTypeName, nodeTypeName);
-        }
-    }
-
-    private String readName() throws RepositoryException {
-        if (readIf("[")) {
-            if (currentTokenType == VALUE) {
-                Value value = readString();
-                read("]");
-                return value.getString();
-            } else {
-                int level = 1;
-                StringBuilder buff = new StringBuilder();
-                while (true) {
-                    if (isToken("]")) {
-                        if (--level <= 0) {
-                            read();
-                            break;
-                        }
-                    } else if (isToken("[")) {
-                        level++;
-                    }
-                    buff.append(readAny());
-                }
-                return buff.toString();
-            }
-        } else {
-            return readAny();
-        }
-    }
-
-    private Source parseSource() throws RepositoryException {
-        Selector selector = parseSelector();
-        selectors.add(selector);
-        Source source = selector;
-        while (true) {
-            JoinType type;
-            if (readIf("RIGHT")) {
-                read("OUTER");
-                type = JoinType.RIGHT;
-            } else if (readIf("LEFT")) {
-                read("OUTER");
-                type = JoinType.LEFT;
-            } else if (readIf("INNER")) {
-                type = JoinType.INNER;
-            } else {
-                break;
-            }
-            read("JOIN");
-            selector = parseSelector();
-            selectors.add(selector);
-            read("ON");
-            JoinCondition on = parseJoinCondition();
-            source = type.join(factory, source, selector, on);
-        }
-        return source;
-    }
-
-    private JoinCondition parseJoinCondition() throws RepositoryException {
-        boolean identifier = currentTokenType == IDENTIFIER;
-        String name = readName();
-        JoinCondition c;
-        if (identifier && readIf("(")) {
-            if ("ISSAMENODE".equalsIgnoreCase(name)) {
-                String selector1 = readName();
-                read(",");
-                String selector2 = readName();
-                if (readIf(",")) {
-                    c = factory.sameNodeJoinCondition(selector1, selector2, readPath());
-                } else {
-                    // TODO verify "." is correct
-                    c = factory.sameNodeJoinCondition(selector1, selector2, ".");
-                }
-            } else if ("ISCHILDNODE".equalsIgnoreCase(name)) {
-                String childSelector = readName();
-                read(",");
-                c = factory.childNodeJoinCondition(childSelector, readName());
-            } else if ("ISDESCENDANTNODE".equalsIgnoreCase(name)) {
-                String descendantSelector = readName();
-                read(",");
-                c = factory.descendantNodeJoinCondition(descendantSelector, readName());
-            } else {
-                throw getSyntaxError("ISSAMENODE, ISCHILDNODE, or ISDESCENDANTNODE");
-            }
-            read(")");
-            return c;
-        } else {
-            String selector1 = name;
-            read(".");
-            String property1 = readName();
-            read("=");
-            String selector2 = readName();
-            read(".");
-            return factory.equiJoinCondition(selector1, property1, selector2, readName());
-        }
-    }
-
-    private Constraint parseConstraint() throws RepositoryException {
-        Constraint a = parseAnd();
-        while (readIf("OR")) {
-            a = factory.or(a, parseAnd());
-        }
-        return a;
-    }
-
-    private Constraint parseAnd() throws RepositoryException {
-        Constraint a = parseCondition();
-        while (readIf("AND")) {
-            a = factory.and(a, parseCondition());
-        }
-        return a;
-    }
-
-    private Constraint parseCondition() throws RepositoryException {
-        Constraint a;
-        if (readIf("NOT")) {
-            a = factory.not(parseConstraint());
-        } else if (readIf("(")) {
-            a = parseConstraint();
-            read(")");
-        } else if (currentTokenType == IDENTIFIER) {
-            String identifier = readName();
-            if (readIf("(")) {
-                a = parseConditionFuntionIf(identifier);
-                if (a == null) {
-                    DynamicOperand op = parseExpressionFunction(identifier);
-                    a = parseCondition(op);
-                }
-            } else if (readIf(".")) {
-                a = parseCondition(factory.propertyValue(identifier, readName()));
-            } else {
-                a = parseCondition(factory.propertyValue(getOnlySelectorName(), identifier));
-            }
-        } else {
-            throw getSyntaxError();
-        }
-        return a;
-    }
-
-    private Constraint parseCondition(DynamicOperand left) throws RepositoryException {
-        Constraint c;
-        if (readIf("=")) {
-            c = Operator.EQ.comparison(factory, left, parseStaticOperand());
-        } else if (readIf("<>")) {
-            c = Operator.NE.comparison(factory, left, parseStaticOperand());
-        } else if (readIf("<")) {
-            c = Operator.LT.comparison(factory, left, parseStaticOperand());
-        } else if (readIf(">")) {
-            c = Operator.GT.comparison(factory, left, parseStaticOperand());
-        } else if (readIf("<=")) {
-            c = Operator.LE.comparison(factory, left, parseStaticOperand());
-        } else if (readIf(">=")) {
-            c = Operator.GE.comparison(factory, left, parseStaticOperand());
-        } else if (readIf("LIKE")) {
-            c = Operator.LIKE.comparison(factory, left, parseStaticOperand());
-        } else if (readIf("IS")) {
-            boolean not = readIf("NOT");
-            read("NULL");
-            if (!(left instanceof PropertyValue)) {
-                throw getSyntaxError("propertyName (NOT NULL is only supported for properties)");
-            }
-            PropertyValue p = (PropertyValue) left;
-            c = getPropertyExistence(p);
-            if (!not) {
-                c = factory.not(c);
-            }
-        } else if (readIf("NOT")) {
-            if (readIf("IS")) {
-                read("NULL");
-                if (!(left instanceof PropertyValue)) {
-                    throw new RepositoryException(
-                            "Only property values can be tested for NOT IS NULL; got: "
-                            + left.getClass().getName());
-                }
-                PropertyValue pv = (PropertyValue) left;
-                c = getPropertyExistence(pv);
-            } else {
-                read("LIKE");
-                c = factory.not(Operator.LIKE.comparison(
-                        factory, left, parseStaticOperand()));
-            }
-        } else {
-            throw getSyntaxError();
-        }
-        return c;
-    }
-
-    private PropertyExistence getPropertyExistence(PropertyValue p) throws InvalidQueryException, RepositoryException {
-        return factory.propertyExistence(p.getSelectorName(), p.getPropertyName());
-    }
-
-    private Constraint parseConditionFuntionIf(String functionName) throws RepositoryException {
-        Constraint c;
-        if ("CONTAINS".equalsIgnoreCase(functionName)) {
-            String name = readName();
-            if (readIf(".")) {
-                if (readIf("*")) {
-                    read(",");
-                    c = factory.fullTextSearch(
-                            name, null, parseStaticOperand());
-                } else {
-                    String selector = name;
-                    name = readName();
-                    read(",");
-                    c = factory.fullTextSearch(
-                            selector, name, parseStaticOperand());
-                }
-            } else {
-                read(",");
-                c = factory.fullTextSearch(
-                        getOnlySelectorName(), name,
-                        parseStaticOperand());
-            }
-        } else if ("ISSAMENODE".equalsIgnoreCase(functionName)) {
-            String name = readName();
-            if (readIf(",")) {
-                c = factory.sameNode(name, readPath());
-            } else {
-                c = factory.sameNode(getOnlySelectorName(), name);
-            }
-        } else if ("ISCHILDNODE".equalsIgnoreCase(functionName)) {
-            String name = readName();
-            if (readIf(",")) {
-                c = factory.childNode(name, readPath());
-            } else {
-                c = factory.childNode(getOnlySelectorName(), name);
-            }
-        } else if ("ISDESCENDANTNODE".equalsIgnoreCase(functionName)) {
-            String name = readName();
-            if (readIf(",")) {
-                c = factory.descendantNode(name, readPath());
-            } else {
-                c = factory.descendantNode(getOnlySelectorName(), name);
-            }
-        } else {
-            return null;
-        }
-        read(")");
-        return c;
-    }
-
-    private String readPath() throws RepositoryException {
-        return readName();
-    }
-
-    private DynamicOperand parseDynamicOperand() throws RepositoryException {
-        boolean identifier = currentTokenType == IDENTIFIER;
-        String name = readName();
-        if (identifier && readIf("(")) {
-            return parseExpressionFunction(name);
-        } else {
-            return parsePropertyValue(name);
-        }
-    }
-
-    private DynamicOperand parseExpressionFunction(String functionName) throws RepositoryException {
-        DynamicOperand op;
-        if ("LENGTH".equalsIgnoreCase(functionName)) {
-            op = factory.length(parsePropertyValue(readName()));
-        } else if ("NAME".equalsIgnoreCase(functionName)) {
-            if (isToken(")")) {
-                op = factory.nodeName(getOnlySelectorName());
-            } else {
-                op = factory.nodeName(readName());
-            }
-        } else if ("LOCALNAME".equalsIgnoreCase(functionName)) {
-            if (isToken(")")) {
-                op = factory.nodeLocalName(getOnlySelectorName());
-            } else {
-                op = factory.nodeLocalName(readName());
-            }
-        } else if ("SCORE".equalsIgnoreCase(functionName)) {
-            if (isToken(")")) {
-                op = factory.fullTextSearchScore(getOnlySelectorName());
-            } else {
-                op = factory.fullTextSearchScore(readName());
-            }
-        } else if ("LOWER".equalsIgnoreCase(functionName)) {
-            op = factory.lowerCase(parseDynamicOperand());
-        } else if ("UPPER".equalsIgnoreCase(functionName)) {
-            op = factory.upperCase(parseDynamicOperand());
-        } else {
-            throw getSyntaxError("LENGTH, NAME, LOCALNAME, SCORE, LOWER, UPPER, or CAST");
-        }
-        read(")");
-        return op;
-    }
-
-    private PropertyValue parsePropertyValue(String name) throws RepositoryException {
-        if (readIf(".")) {
-            return factory.propertyValue(name, readName());
-        } else {
-            return factory.propertyValue(getOnlySelectorName(), name);
-        }
-    }
-
-    private StaticOperand parseStaticOperand() throws RepositoryException {
-        if (currentTokenType == PLUS) {
-            read();
-        } else if (currentTokenType == MINUS) {
-            read();
-            if (currentTokenType != VALUE) {
-                throw getSyntaxError("number");
-            }
-            int valueType = currentValue.getType();
-            switch (valueType) {
-            case PropertyType.LONG:
-                currentValue = valueFactory.createValue(-currentValue.getLong());
-                break;
-            case PropertyType.DOUBLE:
-                currentValue = valueFactory.createValue(-currentValue.getDouble());
-                break;
-            case PropertyType.BOOLEAN:
-                currentValue = valueFactory.createValue(!currentValue.getBoolean());
-                break;
-            case PropertyType.DECIMAL:
-                currentValue = valueFactory.createValue(currentValue.getDecimal().negate());
-                break;
-            default:
-                throw getSyntaxError("Illegal operation: -" + currentValue);
-            }
-        }
-        if (currentTokenType == VALUE) {
-            Literal literal = getUncastLiteral(currentValue);
-            read();
-            return literal;
-        } else if (currentTokenType == PARAMETER) {
-            read();
-            String name = readName();
-            if (readIf(":")) {
-                name = name + ":" + readName();
-            }
-            BindVariableValue var = bindVariables.get(name);
-            if (var == null) {
-                var = factory.bindVariable(name);
-                bindVariables.put(name, var);
-            }
-            return var;
-        } else if (readIf("TRUE")) {
-            Literal literal = getUncastLiteral(valueFactory.createValue(true));
-            return literal;
-        } else if (readIf("FALSE")) {
-            Literal literal = getUncastLiteral(valueFactory.createValue(false));
-            return literal;
-        } else if (readIf("CAST")) {
-            read("(");
-            StaticOperand op = parseStaticOperand();
-            if (!(op instanceof Literal)) {
-                throw getSyntaxError("literal");
-            }
-            Literal literal = (Literal) op;
-            Value value = literal.getLiteralValue();
-            read("AS");
-            value = parseCastAs(value);
-            read(")");
-            // CastLiteral
-            literal = factory.literal(value);
-            return literal;
-        } else {
-            throw getSyntaxError("static operand");
-        }
-    }
-
-    /**
-     * Create a literal from a parsed value.
-     *
-     * @param value the original value
-     * @return the literal
-     */
-    private Literal getUncastLiteral(Value value) throws RepositoryException {
-        return factory.literal(value);
-    }
-
-    private Value parseCastAs(Value value) throws RepositoryException {
-        if (readIf("STRING")) {
-            return valueFactory.createValue(value.getString());
-        } else if(readIf("BINARY")) {
-            return valueFactory.createValue(value.getBinary());
-        } else if(readIf("DATE")) {
-            return valueFactory.createValue(value.getDate());
-        } else if(readIf("LONG")) {
-            return valueFactory.createValue(value.getLong());
-        } else if(readIf("DOUBLE")) {
-            return valueFactory.createValue(value.getDouble());
-        } else if(readIf("DECIMAL")) {
-            return valueFactory.createValue(value.getDecimal());
-        } else if(readIf("BOOLEAN")) {
-            return valueFactory.createValue(value.getBoolean());
-        } else if(readIf("NAME")) {
-            return valueFactory.createValue(value.getString(), PropertyType.NAME);
-        } else if(readIf("PATH")) {
-            return valueFactory.createValue(value.getString(), PropertyType.PATH);
-        } else if(readIf("REFERENCE")) {
-            return valueFactory.createValue(value.getString(), PropertyType.REFERENCE);
-        } else if(readIf("WEAKREFERENCE")) {
-            return valueFactory.createValue(value.getString(), PropertyType.WEAKREFERENCE);
-        } else if(readIf("URI")) {
-            return valueFactory.createValue(value.getString(), PropertyType.URI);
-        } else {
-            throw getSyntaxError("data type (STRING|BINARY|...)");
-        }
-    }
-
-    private Ordering[] parseOrder() throws RepositoryException {
-        ArrayList<Ordering> orderList = new ArrayList<Ordering>();
-        do {
-            Ordering ordering;
-            DynamicOperand op = parseDynamicOperand();
-            if (readIf("DESC")) {
-                ordering = factory.descending(op);
-            } else {
-                readIf("ASC");
-                ordering = factory.ascending(op);
-            }
-            orderList.add(ordering);
-        } while (readIf(","));
-        Ordering[] orderings = new Ordering[orderList.size()];
-        orderList.toArray(orderings);
-        return orderings;
-    }
-
-    private ArrayList<ColumnOrWildcard> parseColumns() throws RepositoryException {
-        ArrayList<ColumnOrWildcard> list = new ArrayList<ColumnOrWildcard>();
-        if (readIf("*")) {
-            list.add(new ColumnOrWildcard());
-        } else {
-            do {
-                ColumnOrWildcard column = new ColumnOrWildcard();
-                column.propertyName = readName();
-                if (readIf(".")) {
-                    column.selectorName = column.propertyName;
-                    if (readIf("*")) {
-                        column.propertyName = null;
-                    } else {
-                        column.propertyName = readName();
-                        if (readIf("AS")) {
-                            column.columnName = readName();
-                        }
-                    }
-                } else {
-                    if (readIf("AS")) {
-                        column.columnName = readName();
-                    }
-                }
-                list.add(column);
-            } while (readIf(","));
-        }
-        return list;
-    }
-
-    private Column[] resolveColumns(ArrayList<ColumnOrWildcard> list) throws RepositoryException {
-        ArrayList<Column> columns = new ArrayList<Column>();
-        for (ColumnOrWildcard c : list) {
-            if (c.propertyName == null) {
-                for (Selector selector : selectors) {
-                    if (c.selectorName == null
-                            || c.selectorName
-                                    .equals(selector.getSelectorName())) {
-                        Column column = factory.column(selector
-                                .getSelectorName(), null, null);
-                        columns.add(column);
-                    }
-                }
-            } else {
-                Column column;
-                if (c.selectorName != null) {
-                    column = factory.column(c.selectorName, c.propertyName, c.columnName);
-                } else if (c.columnName != null) {
-                    column = factory.column(getOnlySelectorName(), c.propertyName, c.columnName);
-                } else {
-                    column = factory.column(getOnlySelectorName(), c.propertyName, c.propertyName);
-                }
-                columns.add(column);
-            }
-        }
-        Column[] array = new Column[columns.size()];
-        columns.toArray(array);
-        return array;
-    }
-
-    private boolean readIf(String token) throws RepositoryException {
-        if (isToken(token)) {
-            read();
-            return true;
-        }
-        return false;
-    }
-
-    private boolean isToken(String token) {
-        boolean result = token.equalsIgnoreCase(currentToken) && !currentTokenQuoted;
-        if (result) {
-            return true;
-        }
-        addExpected(token);
-        return false;
-    }
-
-    private void read(String expected) throws RepositoryException {
-        if (!expected.equalsIgnoreCase(currentToken) || currentTokenQuoted) {
-            throw getSyntaxError(expected);
-        }
-        read();
-    }
-
-    private String readAny() throws RepositoryException {
-        if (currentTokenType == END) {
-            throw getSyntaxError("a token");
-        }
-        String s;
-        if (currentTokenType == VALUE) {
-            s = currentValue.getString();
-        } else {
-            s = currentToken;
-        }
-        read();
-        return s;
-    }
-
-    private Value readString() throws RepositoryException {
-        if (currentTokenType != VALUE) {
-            throw getSyntaxError("string value");
-        }
-        Value value = currentValue;
-        read();
-        return value;
-    }
-
-    private void addExpected(String token) {
-        if (expected != null) {
-            expected.add(token);
-        }
-    }
-
-    private void initialize(String query) throws InvalidQueryException {
-        if (query == null) {
-            query = "";
-        }
-        statement = query;
-        int len = query.length() + 1;
-        char[] command = new char[len];
-        int[] types = new int[len];
-        len--;
-        query.getChars(0, len, command, 0);
-        command[len] = ' ';
-        int startLoop = 0;
-        for (int i = 0; i < len; i++) {
-            char c = command[i];
-            int type = 0;
-            switch (c) {
-            case '/':
-            case '-':
-            case '(':
-            case ')':
-            case '{':
-            case '}':
-            case '*':
-            case ',':
-            case ';':
-            case '+':
-            case '%':
-            case '?':
-            case '$':
-            case '[':
-            case ']':
-                type = CHAR_SPECIAL_1;
-                break;
-            case '!':
-            case '<':
-            case '>':
-            case '|':
-            case '=':
-            case ':':
-                type = CHAR_SPECIAL_2;
-                break;
-            case '.':
-                type = CHAR_DECIMAL;
-                break;
-            case '\'':
-                type = CHAR_STRING;
-                types[i] = CHAR_STRING;
-                startLoop = i;
-                while (command[++i] != '\'') {
-                    checkRunOver(i, len, startLoop);
-                }
-                break;
-            case '\"':
-                type = CHAR_QUOTED;
-                types[i] = CHAR_QUOTED;
-                startLoop = i;
-                while (command[++i] != '\"') {
-                    checkRunOver(i, len, startLoop);
-                }
-                break;
-            case '_':
-                type = CHAR_NAME;
-                break;
-            default:
-                if (c >= 'a' && c <= 'z') {
-                    type = CHAR_NAME;
-                } else if (c >= 'A' && c <= 'Z') {
-                    type = CHAR_NAME;
-                } else if (c >= '0' && c <= '9') {
-                    type = CHAR_VALUE;
-                } else {
-                    if (Character.isJavaIdentifierPart(c)) {
-                        type = CHAR_NAME;
-                    }
-                }
-            }
-            types[i] = (byte) type;
-        }
-        statementChars = command;
-        types[len] = CHAR_END;
-        characterTypes = types;
-        parseIndex = 0;
-    }
-
-    private void checkRunOver(int i, int len, int startLoop) throws InvalidQueryException {
-        if (i >= len) {
-            parseIndex = startLoop;
-            throw getSyntaxError();
-        }
-    }
-
-    private void read() throws RepositoryException {
-        currentTokenQuoted = false;
-        if (expected != null) {
-            expected.clear();
-        }
-        int[] types = characterTypes;
-        int i = parseIndex;
-        int type = types[i];
-        while (type == 0) {
-            type = types[++i];
-        }
-        int start = i;
-        char[] chars = statementChars;
-        char c = chars[i++];
-        currentToken = "";
-        switch (type) {
-        case CHAR_NAME:
-            while (true) {
-                type = types[i];
-                if (type != CHAR_NAME && type != CHAR_VALUE) {
-                    c = chars[i];
-                    break;
-                }
-                i++;
-            }
-            currentToken = statement.substring(start, i);
-            if (currentToken.length() == 0) {
-                throw getSyntaxError();
-            }
-            currentTokenType = IDENTIFIER;
-            parseIndex = i;
-            return;
-        case CHAR_SPECIAL_2:
-            if (types[i] == CHAR_SPECIAL_2) {
-                i++;
-            }
-            // fall through
-        case CHAR_SPECIAL_1:
-            currentToken = statement.substring(start, i);
-            switch (c) {
-            case '$':
-                currentTokenType = PARAMETER;
-                break;
-            case '+':
-                currentTokenType = PLUS;
-                break;
-            case '-':
-                currentTokenType = MINUS;
-                break;
-            case '(':
-                currentTokenType = OPEN;
-                break;
-            case ')':
-                currentTokenType = CLOSE;
-                break;
-            default:
-                currentTokenType = KEYWORD;
-            }
-            parseIndex = i;
-            return;
-        case CHAR_VALUE:
-            long number = c - '0';
-            while (true) {
-                c = chars[i];
-                if (c < '0' || c > '9') {
-                    if (c == '.') {
-                        readDecimal(start, i);
-                        break;
-                    }
-                    if (c == 'E' || c == 'e') {
-                        readDecimal(start, i);
-                        break;
-                    }
-                    checkLiterals(false);
-                    currentValue = valueFactory.createValue(number);
-                    currentTokenType = VALUE;
-                    currentToken = "0";
-                    parseIndex = i;
-                    break;
-                }
-                number = number * 10 + (c - '0');
-                if (number > Integer.MAX_VALUE) {
-                    readDecimal(start, i);
-                    break;
-                }
-                i++;
-            }
-            return;
-        case CHAR_DECIMAL:
-            if (types[i] != CHAR_VALUE) {
-                currentTokenType = KEYWORD;
-                currentToken = ".";
-                parseIndex = i;
-                return;
-            }
-            readDecimal(i - 1, i);
-            return;
-        case CHAR_STRING:
-            readString(i, '\'');
-            return;
-        case CHAR_QUOTED:
-            readString(i, '\"');
-            return;
-        case CHAR_END:
-            currentToken = "";
-            currentTokenType = END;
-            parseIndex = i;
-            return;
-        default:
-            throw getSyntaxError();
-        }
-    }
-
-    private void readString(int i, char end) throws RepositoryException {
-        char[] chars = statementChars;
-        String result = null;
-        while (true) {
-            for (int begin = i;; i++) {
-                if (chars[i] == end) {
-                    if (result == null) {
-                        result = statement.substring(begin, i);
-                    } else {
-                        result += statement.substring(begin - 1, i);
-                    }
-                    break;
-                }
-            }
-            if (chars[++i] != end) {
-                break;
-            }
-            i++;
-        }
-        currentToken = "'";
-        checkLiterals(false);
-        currentValue = valueFactory.createValue(result);
-        parseIndex = i;
-        currentTokenType = VALUE;
-    }
-
-    private void checkLiterals(boolean text) throws InvalidQueryException {
-        if (text && !allowTextLiterals || (!text && !allowNumberLiterals)) {
-            throw getSyntaxError("bind variable (literals of this type not allowed)");
-        }
-    }
-
-    private void readDecimal(int start, int i) throws RepositoryException {
-        char[] chars = statementChars;
-        int[] types = characterTypes;
-        while (true) {
-            int t = types[i];
-            if (t != CHAR_DECIMAL && t != CHAR_VALUE) {
-                break;
-            }
-            i++;
-        }
-        if (chars[i] == 'E' || chars[i] == 'e') {
-            i++;
-            if (chars[i] == '+' || chars[i] == '-') {
-                i++;
-            }
-            if (types[i] != CHAR_VALUE) {
-                throw getSyntaxError();
-            }
-            while (types[++i] == CHAR_VALUE) {
-                // go until the first non-number
-            }
-        }
-        parseIndex = i;
-        String sub = statement.substring(start, i);
-        BigDecimal bd;
-        try {
-            bd = new BigDecimal(sub);
-        } catch (NumberFormatException e) {
-            throw new InvalidQueryException("Data conversion error converting " + sub + " to BigDecimal: " + e);
-        }
-        checkLiterals(false);
-
-        currentValue = valueFactory.createValue(bd);
-        currentTokenType = VALUE;
-    }
-
-    private InvalidQueryException getSyntaxError() {
-        if (expected == null || expected.size() == 0) {
-            return getSyntaxError(null);
-        } else {
-            StringBuilder buff = new StringBuilder();
-            for (String exp : expected) {
-                if (buff.length() > 0) {
-                    buff.append(", ");
-                }
-                buff.append(exp);
-            }
-            return getSyntaxError(buff.toString());
-        }
+        super(factory, valueFactory);
     }
-
-    private InvalidQueryException getSyntaxError(String expected) {
-        int index = Math.min(parseIndex, statement.length() - 1);
-        String query = statement.substring(0, index) + "(*)" + statement.substring(index).trim();
-        if (expected != null) {
-            query += "; expected: " + expected;
-        }
-        return new InvalidQueryException("Query:\n" + query);
-    }
-
-    /**
-     * Represents a column or a wildcard in a SQL expression.
-     * This class is temporarily used during parsing.
-     */
-    private static class ColumnOrWildcard {
-        private String selectorName;
-        private String propertyName;
-        private String columnName;
-    }
-
-    /**
-     * Get the selector name if only one selector exists in the query.
-     * If more than one selector exists, an exception is thrown.
-     *
-     * @return the selector name
-     */
-    private String getOnlySelectorName() throws RepositoryException {
-        if (selectors.size() > 1) {
-            throw getSyntaxError("Need to specify the selector name because the query contains more than one selector.");
-        }
-        return selectors.get(0).getSelectorName();
-    }
-
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java Wed Oct 21 11:38:31 2009
@@ -368,7 +368,14 @@
             public int read(byte[] b, long position) throws IOException, RepositoryException {
                 InputStream in = getStream();
                 try {
-                    in.skip(position);
+                    long skip = position;
+                    while (skip > 0) {
+                        long skipped = in.skip(skip);
+                        if (skipped <= 0) {
+                            return -1;
+                        }
+                        skip -= skipped;
+                    }
                     return in.read(b);
                 } finally {
                     in.close();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/NameParserTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/NameParserTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/NameParserTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/NameParserTest.java Wed Oct 21 11:38:31 2009
@@ -123,8 +123,7 @@
         valid.add(new String[] {"{http://jackrabbit.apache.org:80}abc", "http://jackrabbit.apache.org:80", "abc"});
         valid.add(new String[] {"{http://jackrabbit.apache.org/info}abc", "http://jackrabbit.apache.org/info", "abc"});
         valid.add(new String[] {"{jcr:jackrabbit}abc", "jcr:jackrabbit", "abc"});
-        valid.add(new String[] {"{/jackrabbit/a/b/c}abc", "/jackrabbit/a/b/c", "abc"});
-        valid.add(new String[] {"{abc}def", "abc", "def"});
+        valid.add(new String[] {"{abc:}def", "abc:", "def"});
         valid.add(new String[] {"{}abc", "", "abc"});
 
         for (Iterator it = valid.iterator(); it.hasNext();) {
@@ -146,7 +145,7 @@
         invalid.add("a{b:c");
         invalid.add("a}b:c");
         // unknown uri -> but invalid local name with ':' and or '/'
-        invalid.add("{http//:test.apache.org}abc");
+        invalid.add("{http//test.apache.org}abc");
         invalid.add("{test/test/test}abc");
         // invalid local name containing '/'
         invalid.add("{http://jackrabbit.apache.org}abc/dfg");
@@ -157,7 +156,6 @@
         // invalid local name containing '/'
         invalid.add("/a/b/c");
         // known uri but local name missing -> must fail.
-        invalid.add("{abc}");
         invalid.add("{http://jackrabbit.apache.org}");
         invalid.add("{}");
 
@@ -202,7 +200,6 @@
         valid.add(new String[] {"{http://jackrabbit.apache.org:80}abc", "http://jackrabbit.apache.org:80", "abc"});
         valid.add(new String[] {"{http://jackrabbit.apache.org/info}abc", "http://jackrabbit.apache.org/info", "abc"});
         valid.add(new String[] {"{jcr:jackrabbit}abc", "jcr:jackrabbit", "abc"});
-        valid.add(new String[] {"{/jackrabbit/a/b/c}abc", "/jackrabbit/a/b/c", "abc"});
         valid.add(new String[] {"{abc}def", "abc", "def"});
         valid.add(new String[] {"{}abc", "", "abc"});
 
@@ -231,9 +228,11 @@
         // invalid local name containing '/'
         invalid.add("/a/b/c");
         // known uri but local name missing -> must fail.
-        invalid.add("{abc}");
         invalid.add("{http://jackrabbit.apache.org}");
         invalid.add("{}");
+        // invalid URI part
+        invalid.add("{/jackrabbit/a/b/c}abc");
+
 
         for (Iterator it = invalid.iterator(); it.hasNext();) {
             String jcrName = (String) it.next();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/JcrName.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/JcrName.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/JcrName.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/JcrName.java Wed Oct 21 11:38:31 2009
@@ -54,8 +54,10 @@
         list.add(new JcrName("{}a", "", "a"));
         list.add(new JcrName("{}name", "", "name"));
         list.add(new JcrName("{}na me", "", "na me"));
-        list.add(new JcrName("{prefix}name", "prefix", "name"));
-        list.add(new JcrName("{prefix}na me", "prefix", "na me"));        
+        list.add(new JcrName("{uri:}name", "uri:", "name"));
+        list.add(new JcrName("{uri:}na me", "uri:", "na me"));
+        list.add(new JcrName("{nouri}name", "", "{nouri}name"));
+        list.add(new JcrName("{nouri}na me", "", "{nouri}na me"));
         list.add(new JcrName("{}...", "", "..."));
         list.add(new JcrName("{}.a.", "", ".a."));
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefTest.java Wed Oct 21 11:38:31 2009
@@ -23,13 +23,15 @@
 import java.io.StringWriter;
 import java.util.List;
 
+import junit.framework.TestCase;
+
+import org.apache.jackrabbit.commons.cnd.CompactNodeTypeDefReader;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping;
 import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeDefDiff;
-
-import junit.framework.TestCase;
+import org.apache.jackrabbit.spi.commons.nodetype.QDefinitionBuilderFactory;
 
 public class CompactNodeTypeDefTest extends TestCase {
 
@@ -39,7 +41,9 @@
 
         // Read in node type def from test file
         Reader reader = new InputStreamReader(getClass().getClassLoader().getResourceAsStream(TEST_FILE));
-        CompactNodeTypeDefReader cndReader = new CompactNodeTypeDefReader(reader, TEST_FILE);
+        CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping> cndReader =
+            new CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping>(
+                reader, TEST_FILE, new QDefinitionBuilderFactory());
 
         List<QNodeTypeDefinition> ntdList1 = cndReader.getNodeTypeDefinitions();
         NamespaceMapping nsm = cndReader.getNamespaceMapping();
@@ -50,7 +54,8 @@
         CompactNodeTypeDefWriter.write(ntdList1, nsm, resolver, sw);
 
         // Rerun the reader on the product of the writer
-        cndReader = new CompactNodeTypeDefReader(new StringReader(sw.toString()), TEST_FILE);
+        cndReader = new CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping>(
+                new StringReader(sw.toString()), TEST_FILE, new QDefinitionBuilderFactory());
 
         List<QNodeTypeDefinition> ntdList2 = cndReader.getNodeTypeDefinitions();
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/resources/org/apache/jackrabbit/spi/commons/query/sql2/test.sql2.txt
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/resources/org/apache/jackrabbit/spi/commons/query/sql2/test.sql2.txt?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/resources/org/apache/jackrabbit/spi/commons/query/sql2/test.sql2.txt (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/resources/org/apache/jackrabbit/spi/commons/query/sql2/test.sql2.txt Wed Oct 21 11:38:31 2009
@@ -69,12 +69,14 @@
 # 6.7.15 Not (p 110)
 select * from test where not id=2
 select * from test where not (id=2 and name='Hello')
+select * from test where not ([id]=2 and [name]='Hello')
 select * from test where id=2 or not (name='Hello' and id=3)
 
 # 6.7.16 Comparison (p 110)
 # 6.7.17 Operator (p 112)
 select * from test where id<=2 or id>=3 and name<'a' or name>'c'
 select * from test where id<>2
+select * from [test] where [id]<>2
 select * from test where name like 'H%'
 
 # 6.7.18 PropertyExistence (p 113)
@@ -114,6 +116,10 @@
 # 6.7.28 Length (p 120)
 select * from test where length(name)=5
 select * from test as t where length(t.name)=5
+select * from test as t where length(name)=5
+SELECT * FROM [my:thing] WHERE [my:property] = 'abc'
+SELECT * FROM [my:thing] AS thing WHERE [my:property] = 'abc'
+SELECT * FROM [my:thing] AS [thing] WHERE [thing].[my:property] = 'abc'
 
 # 6.7.29 NodeName (p 121)
 select * from test where name()='test'

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi/pom.xml?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi/pom.xml (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi/pom.xml Wed Oct 21 11:38:31 2009
@@ -34,6 +34,7 @@
   </parent>
   <artifactId>jackrabbit-spi</artifactId>
   <name>Jackrabbit SPI</name>
+  <packaging>bundle</packaging>
 
   <scm>
     <connection>
@@ -47,6 +48,18 @@
 
   <build>
     <plugins>
+        <plugin>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>maven-bundle-plugin</artifactId>
+          <extensions>true</extensions>
+          <configuration>
+            <instructions>
+              <Export-Package>
+                org.apache.jackrabbit.spi;version=${pom.version}
+              </Export-Package>
+            </instructions>
+          </configuration>
+        </plugin>
       <plugin>
         <artifactId>maven-assembly-plugin</artifactId>
         <executions>

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/ExceptionConverter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/ExceptionConverter.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/ExceptionConverter.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/ExceptionConverter.java Wed Oct 21 11:38:31 2009
@@ -88,16 +88,29 @@
                                        method instanceof PutMethod)) {
                     // target item has probably while transient changes have
                     // been made.
-                    throw new InvalidItemStateException(msg);
+                    throw new InvalidItemStateException(msg, davExc);
                 } else {
-                    return new ItemNotFoundException(msg);
+                    return new ItemNotFoundException(msg, davExc);
                 }
-            case DavServletResponse.SC_LOCKED : return new LockException(msg);
-            case DavServletResponse.SC_METHOD_NOT_ALLOWED : return new ConstraintViolationException(msg);
-            case DavServletResponse.SC_CONFLICT : return new InvalidItemStateException(msg);
-            case DavServletResponse.SC_PRECONDITION_FAILED : return new LockException(msg);
-            case DavServletResponse.SC_NOT_IMPLEMENTED: throw new UnsupportedOperationException("Missing implementation. " + ((method != null) ? "Method " + method + " could not be executed." : ""));
-            default: return new RepositoryException(msg);
+            case DavServletResponse.SC_LOCKED :
+                return new LockException(msg, davExc);
+            case DavServletResponse.SC_METHOD_NOT_ALLOWED :
+                return new ConstraintViolationException(msg, davExc);
+            case DavServletResponse.SC_CONFLICT :
+                return new InvalidItemStateException(msg, davExc);
+            case DavServletResponse.SC_PRECONDITION_FAILED :
+                return new LockException(msg, davExc);
+            case DavServletResponse.SC_NOT_IMPLEMENTED:
+                if (method != null) {
+                    throw new UnsupportedOperationException(
+                            "Missing implementation: Method "
+                            + method + " could not be executed", davExc);
+                } else {
+                    throw new UnsupportedOperationException(
+                            "Missing implementation", davExc);
+                }
+            default:
+                return new RepositoryException(msg, davExc);
         }
     }
 }
\ No newline at end of file

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java Wed Oct 21 11:38:31 2009
@@ -42,6 +42,9 @@
 import org.apache.jackrabbit.spi.Event;
 import org.apache.jackrabbit.spi.commons.EventFilterImpl;
 import org.apache.jackrabbit.spi.commons.EventBundleImpl;
+import org.apache.jackrabbit.spi.commons.QPropertyDefinitionImpl;
+import org.apache.jackrabbit.spi.commons.QNodeDefinitionImpl;
+import org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeDefinitionImpl;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
@@ -1229,10 +1232,10 @@
     /**
      * {@inheritDoc}
      */
-    public Iterator getQNodeTypeDefinitions(SessionInfo sessionInfo) throws RepositoryException {
+    public Iterator<QNodeTypeDefinition> getQNodeTypeDefinitions(SessionInfo sessionInfo) throws RepositoryException {
         SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
         NodeTypeManager ntMgr = sInfo.getSession().getWorkspace().getNodeTypeManager();
-        List nodeTypes = new ArrayList();
+        List<QNodeTypeDefinition> nodeTypes = new ArrayList<QNodeTypeDefinition>();
         try {
             for (NodeTypeIterator it = ntMgr.getAllNodeTypes(); it.hasNext(); ) {
                 NodeType nt = it.nextNodeType();
@@ -1248,20 +1251,22 @@
     /**
      * {@inheritDoc}
      */
-    public Iterator getQNodeTypeDefinitions(SessionInfo sessionInfo, Name[] nodetypeNames) throws RepositoryException {
+    public Iterator<QNodeTypeDefinition> getQNodeTypeDefinitions(SessionInfo sessionInfo, Name[] nodetypeNames) throws RepositoryException {
         SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
         NodeTypeManager ntMgr = sInfo.getSession().getWorkspace().getNodeTypeManager();
-        List defs = new ArrayList();
-        for (int i = 0; i < nodetypeNames.length; i++) {
+        List<QNodeTypeDefinition> defs = new ArrayList<QNodeTypeDefinition>();
+        for (Name nodetypeName : nodetypeNames) {
             try {
-                String ntName = sInfo.getNamePathResolver().getJCRName(nodetypeNames[i]);
+                String ntName = sInfo.getNamePathResolver().getJCRName(nodetypeName);
                 NodeType nt = ntMgr.getNodeType(ntName);
-                defs.add(new QNodeTypeDefinitionImpl(nt, sInfo.getNamePathResolver(), getQValueFactory()));
+                defs.add(new QNodeTypeDefinitionImpl(nt, 
+                        sInfo.getNamePathResolver(), getQValueFactory()));
 
                 // in addition pack all supertypes into the return value
                 NodeType[] supertypes = nt.getSupertypes();
-                for (int st = 0; st < supertypes.length; st++) {
-                    defs.add(new QNodeTypeDefinitionImpl(supertypes[i], sInfo.getNamePathResolver(), getQValueFactory()));
+                for (NodeType supertype : supertypes) {
+                    defs.add(new QNodeTypeDefinitionImpl(supertype,
+                            sInfo.getNamePathResolver(), getQValueFactory()));
                 }
             } catch (NameException e) {
                 throw new RepositoryException(e);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-standalone/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-standalone/pom.xml?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-standalone/pom.xml (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-standalone/pom.xml Wed Oct 21 11:38:31 2009
@@ -40,6 +40,12 @@
   <build>
     <plugins>
       <plugin>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+      <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
         <extensions>true</extensions>
@@ -49,12 +55,7 @@
               org.apache.jackrabbit.standalone
             </Export-Package>
             <Embed-Dependency>
-              *;inline=
-              *.txt|*.html|*.jsp|*.xml|*.jar|*.properties|
-              remoting/**|bootstrap/**|javax/**|repackage/**|images/**|
-              com/**|Resources/**|css/**|schema*/**|EDU/**|error/**|org/**|
-              META-INF/*.tld|META-INF/maven/**|META-INF/services/**|
-              WEB-INF/config.xml|WEB-INF/*.properties|WEB-INF/templates/**
+              *;inline=*.txt|*.html|*.jsp|*.xml|*.jar|*.properties|remoting/**|bootstrap/**|javax/**|repackage/**|images/**|com/**|Resources/**|css/**|schema*/**|EDU/**|error/**|org/**|META-INF/*.tld|META-INF/maven/**|META-INF/services/**|WEB-INF/config.xml|WEB-INF/*.properties|WEB-INF/templates/**
             </Embed-Dependency>
             <Embed-Transitive>true</Embed-Transitive>
             <Main-Class>org.apache.jackrabbit.standalone.Main</Main-Class>

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-standalone/src/main/resources/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-standalone/src/main/resources/WEB-INF/web.xml?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-standalone/src/main/resources/WEB-INF/web.xml (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-standalone/src/main/resources/WEB-INF/web.xml Wed Oct 21 11:38:31 2009
@@ -130,16 +130,11 @@
     </servlet>
 
     <!-- ====================================================================== -->
-    <!-- R M I   B I N D I N G   S E R V L E T S                                -->
+    <!-- R M I   B I N D I N G   S E R V L E T                                  -->
     <!-- ====================================================================== -->
     <servlet>
       <servlet-name>RMI</servlet-name>
-      <servlet-class>org.apache.jackrabbit.servlet.remote.RMIRemoteBindingServlet</servlet-class>
-        <init-param>
-            <param-name>url</param-name>
-            <param-value>//localhost/jackrabbit.repository</param-value>
-        </init-param>
-        <load-on-startup>6</load-on-startup>
+      <servlet-class>org.apache.jackrabbit.servlet.remote.RemoteBindingServlet</servlet-class>
     </servlet>
 
     <!-- ====================================================================== -->

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-webapp/src/main/webapp/search.jsp
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-webapp/src/main/webapp/search.jsp?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-webapp/src/main/webapp/search.jsp (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-webapp/src/main/webapp/search.jsp Wed Oct 21 11:38:31 2009
@@ -69,12 +69,12 @@
             String stmt;
             if (q.startsWith("related:")) {
                 String path = q.substring("related:".length());
-                stmt = "//element(*, nt:file)[rep:similar(jcr:content, '" + path + "/jcr:content')]/rep:excerpt(.)";
+                stmt = "//element(*, nt:file)[rep:similar(jcr:content, '" + path + "/jcr:content')]/rep:excerpt(.) order by @jcr:score descending";
                 queryTerms = "similar to <b>" + Text.encodeIllegalXMLCharacters(path) + "</b>";
             } else {
                 queryTerms = "for <b>" + Text.encodeIllegalXMLCharacters(q) + "</b>";
                 q = q.replaceAll("'", "''");
-                stmt = "//element(*, nt:file)[jcr:contains(jcr:content, '" + q + "')]/rep:excerpt(.)";
+                stmt = "//element(*, nt:file)[jcr:contains(jcr:content, '" + q + "')]/rep:excerpt(.) order by @jcr:score descending";
             }
             Query query = jcrSession.getWorkspace().getQueryManager().createQuery(stmt, Query.XPATH);
             long time = System.currentTimeMillis();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/DavMethodBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/DavMethodBase.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/DavMethodBase.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/DavMethodBase.java Wed Oct 21 11:38:31 2009
@@ -119,9 +119,14 @@
                 responseDocument = docBuilder.parse(in);
                 return responseDocument;
             } catch (ParserConfigurationException e) {
-                throw new IOException(e.getMessage());
+                IOException exception =
+                    new IOException("XML parser configuration error");
+                exception.initCause(e);
+                throw exception;
             } catch (SAXException e) {
-                throw new IOException(e.getMessage());
+                IOException exception = new IOException("XML parsing error");
+                exception.initCause(e);
+                throw exception;
             } finally {
                 in.close();
             }
@@ -206,7 +211,10 @@
             doc.appendChild(requestBody.toXml(doc));
             setRequestBody(doc);
         } catch (ParserConfigurationException e) {
-            throw new IOException(e.getMessage());
+            IOException exception =
+                new IOException("XML parser configuration error");
+            exception.initCause(e);
+            throw exception;
         }
     }
 

Modified: jackrabbit/sandbox/JCR-1456/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/pom.xml?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/pom.xml (original)
+++ jackrabbit/sandbox/JCR-1456/pom.xml Wed Oct 21 11:38:31 2009
@@ -44,7 +44,6 @@
     <module>jackrabbit-jcr-commons</module>
     <module>jackrabbit-jcr-tests</module>
     <module>jackrabbit-core</module>
-    <module>jackrabbit-text-extractors</module>
     <module>jackrabbit-webdav</module>
     <module>jackrabbit-jcr-server</module>
     <module>jackrabbit-webapp</module>
@@ -64,4 +63,15 @@
     <url>http://svn.apache.org/viewvc/jackrabbit/trunk</url>
   </scm>
 
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
 </project>



Mime
View raw message