You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2009/01/30 10:04:40 UTC

svn commit: r739210 - in /jackrabbit/trunk: jackrabbit-jcr-commons/ jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/ jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/ jackrabbit-jcr-commons/src/test/java/org/apach...

Author: angela
Date: Fri Jan 30 09:04:39 2009
New Revision: 739210

URL: http://svn.apache.org/viewvc?rev=739210&view=rev
Log:
- JCR-1958: Enhanced JCR remoting (work in progress)

Added:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonHandler.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonParser.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonUtil.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/
    jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonParserTest.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonUtilTest.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/TestAll.java   (with props)
Modified:
    jackrabbit/trunk/jackrabbit-jcr-commons/pom.xml
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/TextTest.java
    jackrabbit/trunk/jackrabbit-parent/pom.xml

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/pom.xml?rev=739210&r1=739209&r2=739210&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/pom.xml Fri Jan 30 09:04:39 2009
@@ -79,6 +79,11 @@
       <artifactId>cglib</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.json</groupId>
+      <artifactId>json</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
 </project>

Added: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonHandler.java?rev=739210&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonHandler.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonHandler.java Fri Jan 30 09:04:39 2009
@@ -0,0 +1,94 @@
+/*
+ * 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.commons.json;
+
+import java.io.IOException;
+
+/**
+ * The <code>JSONHandler</code> interface recieves notifications from the
+ * <code>JsonParser</code>.
+ */
+public interface JsonHandler {
+
+    /**
+     * Recieve notification about the start of an JSON object.
+     *
+     * @throws IOException If an error occurs.
+     */
+    void object() throws IOException;
+
+    /**
+     * Recieve notification about the end of an JSON object.
+     *
+     * @throws IOException If an error occurs.
+     */
+    void endObject() throws IOException;
+
+    /**
+     * Recieve notification about the start of an JSON array.
+     *
+     * @throws IOException If an error occurs.
+     */
+    void array() throws IOException;
+
+    /**
+     * Recieve notification about the end of an JSON array.
+     *
+     * @throws IOException If an error occurs.
+     */
+    void endArray() throws IOException;
+
+    /**
+     * Recieve notification about the given JSON key.
+     *
+     * @param key The key.
+     * @throws IOException If an error occurs.
+     */
+    void key(String key) throws IOException;
+
+    /**
+     * Recieve notification about the given JSON String value.
+     *
+     * @param value The value.
+     * @throws IOException If an error occurs.
+     */
+    void value(String value) throws IOException;
+
+    /**
+     * Recieve notification about the given JSON boolean value.
+     *
+     * @param value The value.
+     * @throws IOException If an error occurs.
+     */
+    void value(boolean value) throws IOException;
+
+    /**
+     * Recieve notification about the given JSON number value (long).
+     *
+     * @param value The value.
+     * @throws IOException If an error occurs.
+     */
+    void value(long value) throws IOException;
+
+    /**
+     * Recieve notification about the given JSON number value (double).
+     *
+     * @param value The value.
+     * @throws IOException If an error occurs.
+     */
+    void value(double value) throws IOException;
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonHandler.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonParser.java?rev=739210&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonParser.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonParser.java Fri Jan 30 09:04:39 2009
@@ -0,0 +1,296 @@
+/*
+ * 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.commons.json;
+
+import java.io.BufferedReader;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Stack;
+
+/**
+ * <code>JsonParser</code> parses and validates the JSON object passed upon 
+ * {@link #parse(String)} or {@link #parse(InputStream, String)} and notifies
+ * the specified <code>JsonHandler</code>
+ */
+public class JsonParser {
+
+    private static final String NULL = "null";
+    private static final int EOF = -1;
+
+    private static final int KEY_START = 1;
+    private static final int VALUE_START = 2;
+    private static final int VALUE = 4;
+
+    private static final Integer OBJECT = new Integer(8);
+    private static final Integer ARRAY = new Integer(32);
+
+    /* the handler */
+    private final JsonHandler handler;
+
+    /**
+     * Create a new <code>JSONParser</code> with the specified <code>JSONHandler</code>.
+     *
+     * @param jsonHandler A <code>JSONHandler</code>
+     */
+    public JsonParser(JsonHandler jsonHandler) {
+        handler = jsonHandler;
+    }
+
+    /**
+     *
+     * @param str String to be parsed
+     * @throws IOException If an error occurs.
+     */
+    public void parse(String str) throws IOException {
+        parse(new BufferedReader(new StringReader(str)));
+    }
+
+    /**
+     *
+     * @param input InputStream to be parsed.
+     * @param charSetName Name of the charset to be used.
+     * @throws IOException If an error occurs.
+     */
+    public void parse(InputStream input, String charSetName) throws IOException {
+        parse(new BufferedReader(new InputStreamReader(input, charSetName)));
+    }
+
+    /**
+     *
+     * @param reader The reader
+     * @throws IOException If an error occurs.
+     */
+    public void parse(Reader reader) throws IOException {
+
+        //StringBuffer key = new StringBuffer();
+        StringBuffer value = new StringBuffer();
+
+        int state;
+        Stack complexVStack = new Stack();
+
+        int next = reader.read();
+        if (next == '{') {
+            handler.object();
+            complexVStack.push(OBJECT);
+            state = KEY_START;
+            next = readIgnoreWhitespace(reader);
+        } else {
+            throw new IOException("JSON object must start with a '{'");
+        }
+
+
+        while (next != EOF) {
+            switch (state) {
+
+                case KEY_START:
+                    if (next == '"') {
+                        String key = nextString(reader, '\"');
+                        next = readIgnoreWhitespace(reader);
+                        if (next == ':') {
+                            handler.key(key);
+                            state = VALUE_START;
+                        } else {
+                            throw new IOException("Key-Value pairs must be separated by ':'");
+                        }
+                        next = readIgnoreWhitespace(reader);
+                    } else if (next == '}') {
+                        // empty object
+                        state = VALUE;
+                    } else {
+                        throw new IOException("Key must be in String format (double quotes)");
+                    }
+                    break;
+
+                case VALUE_START:
+                    if (next == '[') {
+                        handler.array();
+                        complexVStack.push(ARRAY);
+                        // status still value_start
+                        next = readIgnoreWhitespace(reader);
+                    } else if (next == '{') {
+                        handler.object();
+                        complexVStack.push(OBJECT);
+                        state = KEY_START;
+                        next = readIgnoreWhitespace(reader);
+                    } else if (next == '\"') {
+                        handler.value(nextString(reader, '\"'));
+                        next = readIgnoreWhitespace(reader);
+                        if (!(next == ',' || next == ']' || next == '}')) {
+                            throw new IOException("Invalid json format");
+                        }
+                    } else {
+                        // start of boolean/long/double/null value
+                        // will be notified as key-value pair
+                        state = VALUE;
+                    }
+                    break;
+
+                case VALUE:
+                    if (next == '"') {
+                        throw new IOException("Invalid json format");
+                    } else if (next == ',') {
+                        state = (complexVStack.peek() == OBJECT) ? KEY_START : VALUE_START;
+                        value = resetValue(value);
+                        next = readIgnoreWhitespace(reader);
+                    } else if (next == ']') {
+                        if (complexVStack.pop() != ARRAY) {
+                            throw new IOException("Invalid json format: Unexpected array termination.");
+                        }
+                        value = resetValue(value);
+                        handler.endArray();
+
+                        next = readIgnoreWhitespace(reader);
+                        if (!(next == ',' || next == '}' || next == ']')) {
+                            throw new IOException("Invalid json format");
+                        }
+                    } else if (next == '}') {
+                        if (complexVStack.pop() != OBJECT) {
+                            throw new IOException("Invalid json format: Unexpected object termination.");
+                        }
+                        value = resetValue(value);
+                        handler.endObject();
+
+                        next = readIgnoreWhitespace(reader);
+                        if (!(next == ',' || next == '}' || next == ']' || next == EOF)) {
+                            throw new IOException("Invalid json format");
+                        }
+                    } else {
+                        // simple value
+                        value.append((char) next);
+                        next = reader.read();
+                    }
+                    break;
+            }
+        }
+
+        // EOF reached -> minimal validation check
+        if (value.length() != 0) {
+            throw new IOException("Invalid json format");
+        }
+    }
+
+    /**
+     * Return the characters up to the next close quote character.
+     * Backslash processing is done. The formal JSON format does not
+     * allow strings in single quotes, but an implementation is allowed to
+     * accept them.
+     *
+     * @param r The reader.
+     * @param quote The quoting character, either
+     *      <code>"</code>&nbsp;<small>(double quote)</small> or
+     *      <code>'</code>&nbsp;<small>(single quote)</small>.
+     * @return      A String.
+     * @throws IOException Unterminated string.
+     */
+    private static String nextString(Reader r, char quote) throws IOException {
+        int c;
+        StringBuffer sb = new StringBuffer();
+        for (;;) {
+            c = r.read();
+            switch (c) {
+            case EOF:
+            case '\n':
+            case '\r':
+                throw new IOException("Unterminated string");
+            case '\\':
+                c = r.read();
+                switch (c) {
+                case 'b':
+                    sb.append('\b');
+                    break;
+                case 't':
+                    sb.append('\t');
+                    break;
+                case 'n':
+                    sb.append('\n');
+                    break;
+                case 'f':
+                    sb.append('\f');
+                    break;
+                case 'r':
+                    sb.append('\r');
+                    break;
+                case 'u':
+                    sb.append((char)Integer.parseInt(next(r, 4), 16));
+                    break;
+                case 'x' :
+                    sb.append((char) Integer.parseInt(next(r, 2), 16));
+                    break;
+                default:
+                    sb.append((char) c);
+                }
+                break;
+            default:
+                if (c == quote) {
+                    return sb.toString();
+                }
+                sb.append((char) c);
+            }
+        }
+    }
+
+    private static String next(Reader r, int n) throws IOException {
+        StringBuffer b = new StringBuffer(n);
+        while (n-- > 0) {
+            int c = r.read();
+            if (c < 0) {
+                throw new EOFException();
+            }
+            b.append((char) c);
+        }
+        return b.toString();
+    }
+
+    /**
+     * Get the next char in the string, skipping whitespace.
+     *
+     * @param reader The reader
+     * @return A character, or -1 if there are no more characters.
+     * @throws IOException If an error occurs.
+     */
+    private static int readIgnoreWhitespace(Reader reader) throws IOException {
+        int next;
+        do {
+            next = reader.read();
+        } while (next == ' ' || next == '\n' || next == '\r' || next == '\t');
+        return next;
+    }
+
+    private StringBuffer resetValue(StringBuffer value) throws IOException {
+        if (value != null && value.length() > 0) {
+            String v = value.toString();
+            if (NULL.equals(v)) {
+                handler.value(null);
+            } else if (v.equalsIgnoreCase("true")) {
+                handler.value(true);
+            } else if (v.equalsIgnoreCase("false")) {
+                handler.value(false);
+            } else if (v.indexOf('.') > -1) {
+                double d = Double.parseDouble(v);
+                handler.value(d);
+            } else {
+                long l = Long.parseLong(v);
+                handler.value(l);
+            }
+        }
+        return new StringBuffer();
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonParser.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonUtil.java?rev=739210&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonUtil.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonUtil.java Fri Jan 30 09:04:39 2009
@@ -0,0 +1,86 @@
+/*
+ * 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.commons.json;
+
+/**
+ * JSON utilities.
+ */
+public class JsonUtil {
+
+    /**
+     * Generate a valid JSON string from the given <code>str</code>.
+     *
+     * @param str A String
+     * @return JSON string surrounded by double quotes.
+     * @see <a href="http://tools.ietf.org/html/rfc4627">RFC 4627</a>
+     */
+    public static String getJsonString(String str) {
+        if (str == null || str.length() == 0) {
+            return "\"\"";
+        }
+
+        int len = str.length();
+        StringBuffer sb = new StringBuffer(len + 2);
+        // leading quote
+        sb.append('"');
+        // append passed string escaping characters as required
+        for (int i = 0; i < len; i++) {
+            char c = str.charAt(i);
+            switch (c) {
+                // reverse solidus and double quote
+                case '\\':
+                case '"':
+                    sb.append('\\').append(c);
+                    break;
+                // tab, line breaking chars and backspace
+                case '\b':
+                    sb.append("\\b");
+                    break;
+                case '\f':
+                    sb.append("\\f");
+                    break;
+                case '\n':
+                    sb.append("\\n");
+                    break;
+                case '\r':
+                    sb.append("\\r");
+                    break;
+                case '\t':
+                    sb.append("\\t");
+                    break;
+                // other control characters and 'unescaped'
+                default:
+                    if (c < 32) {
+                        // control characters except those already covered above.
+                        String uc = Integer.toHexString(c);
+                        sb.append("\\u");
+                        int uLen = uc.length();
+                        while (uLen++ < 4) {
+                            sb.append('0');
+                        }
+                        sb.append(uc);
+                    } else {
+                        // unescaped = %x20-21 / %x23-5B / %x5D-10FFFF
+                        sb.append(c);
+                    }
+            }
+        }
+        // trailing quote
+        sb.append('"');
+        return sb.toString();
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/JsonUtil.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java?rev=739210&r1=739209&r2=739210&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java Fri Jan 30 09:04:39 2009
@@ -763,67 +763,4 @@
 
         return result.toString();
     }
-
-    /**
-     * Generate a valid JSON string from the given <code>str</code>.
-     * 
-     * @param str A String
-     * @return JSON string surrounded by double quotes.
-     * @see <a href="http://tools.ietf.org/html/rfc4627">RFC 4627</a>
-     */
-    public static String getJSONString(String str) {
-        if (str == null || str.length() == 0) {
-            return "\"\"";
-        }
-
-        int len = str.length();
-        StringBuffer sb = new StringBuffer(len + 2);
-        // leading quote
-        sb.append('"');
-        // append passed string escaping characters as required
-        for (int i = 0; i < len; i++) {
-            char c = str.charAt(i);
-            switch (c) {
-                // reverse solidus and double quote
-                case '\\':
-                case '"':
-                    sb.append('\\').append(c);
-                    break;
-                // tab, line breaking chars and backspace
-                case '\b':
-                    sb.append("\\b");
-                    break;
-                case '\f':
-                    sb.append("\\f");
-                    break;
-                case '\n':
-                    sb.append("\\n");
-                    break;
-                case '\r':
-                    sb.append("\\r");
-                    break;
-                case '\t':
-                    sb.append("\\t");
-                    break;
-                // other control characters and 'unescaped'
-                default:
-                    if (c < 32) {
-                        // control characters except those already covered above.
-                        String uc = Integer.toHexString(c);
-                        sb.append("\\u");
-                        int uLen = uc.length();
-                        while (uLen++ < 4) {
-                            sb.append('0');
-                        }
-                        sb.append(uc);
-                    } else {
-                        // unescaped = %x20-21 / %x23-5B / %x5D-10FFFF
-                        sb.append(c);
-                    }
-            }
-        }
-        // trailing quote
-        sb.append('"');
-        return sb.toString();
-    }
 }

Added: jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonParserTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonParserTest.java?rev=739210&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonParserTest.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonParserTest.java Fri Jan 30 09:04:39 2009
@@ -0,0 +1,584 @@
+/*
+ * 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.commons.json;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * <code>JSONParserTest</code>...
+ */
+public class JsonParserTest extends TestCase {
+
+    private final JsonHandler handler = new DummyJsonHandler();
+
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    public void testParser() throws Exception {
+        // TODO validate output. use specific handler ext.
+        JsonParser parser = new JsonParser(handler);
+        parser.parse(getObj().toString());
+    }
+
+    public void testParseBooleanValue() throws Exception {
+        JSONObject obj = new JSONObject();
+        obj.put("boolean", true);
+
+        JsonHandler handler = new DummyJsonHandler() {
+            public void key(String key) {
+                assertEquals("boolean", key);
+            }
+            public void value(String value) {
+                fail();
+            }
+            public void value(long value) {
+                fail();
+            }
+            public void value(double value) {
+                fail();
+            }
+            public void value(boolean value) {
+                assertEquals(true, value);
+            }
+        };
+        JsonParser parser = new JsonParser(handler);
+        parser.parse(obj.toString());
+    }
+
+    public void testParseLongValue() throws Exception {
+        JSONObject obj = new JSONObject();
+        obj.put("long", 123456);
+
+        JsonHandler handler = new DummyJsonHandler() {
+            public void key(String key) {
+                assertEquals("long", key);
+            }
+            public void value(String value) {
+                fail();
+            }
+            public void value(double value) {
+                fail();
+            }
+            public void value(boolean value) {
+                fail();
+            }
+            public void value(long value) {
+                assertEquals(123456, value);
+            }
+        };
+        JsonParser parser = new JsonParser(handler);
+        parser.parse(obj.toString());
+    }
+
+    public void testDoubleValue() throws Exception {
+        JSONObject obj = new JSONObject();
+        obj.put("double", 1235674.342424);
+
+        JsonHandler handler = new DummyJsonHandler() {
+            public void key(String key) {
+                assertEquals("double", key);
+            }
+            public void value(String value) {
+                fail();
+            }
+            public void value(long value) {
+                fail();
+            }
+            public void value(boolean value) {
+                fail();
+            }
+            public void value(double value) {
+                assertEquals(new Double(1235674.342424), new Double(value));
+            }
+        };
+        JsonParser parser = new JsonParser(handler);
+        parser.parse(obj.toString());
+    }
+
+    public void testStringValue() throws Exception {
+        JSONObject obj = new JSONObject();
+        obj.put("string", "abc");
+
+        JsonHandler handler = new DummyJsonHandler() {
+            public void key(String key) {
+                assertEquals("string", key);
+            }
+            public void value(String value) {
+                assertEquals("abc", value);
+            }
+            public void value(long value) {
+                fail();
+            }
+            public void value(double value) {
+                fail();
+            }
+            public void value(boolean value) {
+                fail();
+            }
+        };
+        JsonParser parser = new JsonParser(handler);
+        parser.parse(obj.toString());
+    }
+
+    public void testStringWithQuoteValue() throws Exception {
+        JSONObject obj = new JSONObject();
+        obj.put("string", "abc\"abc");
+
+        JsonHandler handler = new DummyJsonHandler() {
+            public void key(String key) {
+                assertEquals("string", key);
+            }
+            public void value(String value) {
+                assertEquals("abc\"abc", value);
+            }
+            public void value(long value) {
+                fail();
+            }
+            public void value(double value) {
+                fail();
+            }
+            public void value(boolean value) {
+                fail();
+            }
+        };
+        JsonParser parser = new JsonParser(handler);
+        parser.parse(obj.toString());
+    }
+
+    public void testStringWithBackSlashValue() throws Exception {
+        JSONObject obj = new JSONObject();
+        obj.put("string", "abc\\abc");
+
+        JsonHandler handler = new DummyJsonHandler() {
+            public void key(String key) {
+                assertEquals("string", key);
+            }
+            public void value(String value) {
+                assertEquals("abc\\abc", value);
+            }
+            public void value(long value) {
+                fail();
+            }
+            public void value(double value) {
+                fail();
+            }
+            public void value(boolean value) {
+                fail();
+            }
+        };
+        JsonParser parser = new JsonParser(handler);
+        parser.parse(obj.toString());
+    }
+
+    public void testStringWithBackSlashValue2() throws Exception {
+        JSONObject obj = new JSONObject();
+        obj.put("string", "\'abc\\\\x\\'abc");
+
+        JsonHandler handler = new DummyJsonHandler() {
+            public void key(String key) {
+                assertEquals("string", key);
+            }
+            public void value(String value) {
+                assertEquals("\'abc\\\\x\\'abc", value);
+            }
+            public void value(long value) {
+                fail();
+            }
+            public void value(double value) {
+                fail();
+            }
+            public void value(boolean value) {
+                fail();
+            }
+        };
+        JsonParser parser = new JsonParser(handler);
+        parser.parse(obj.toString());
+    }
+
+    public void testStringWithUnicode() throws Exception {
+        JSONObject obj = new JSONObject();
+        obj.put("string", "abc\u2345ab\u00EB\u0633c");
+
+        JsonHandler handler = new DummyJsonHandler() {
+            public void key(String key) {
+                assertEquals("string", key);
+            }
+            public void value(String value) {
+                assertEquals("abc\u2345ab\u00EB\u0633c", value);
+                assertEquals("abc\u2345abë\u0633c", value);
+            }
+            public void value(long value) {
+                fail();
+            }
+            public void value(double value) {
+                fail();
+            }
+            public void value(boolean value) {
+                fail();
+            }
+        };
+        JsonParser parser = new JsonParser(handler);
+        parser.parse(obj.toString());
+    }
+
+    public void testStringWithUnicode2() throws Exception {
+        JSONObject obj = new JSONObject();
+        obj.put("string", "\u00EB");
+
+        JsonHandler handler = new DummyJsonHandler() {
+            public void key(String key) {
+                assertEquals("string", key);
+            }
+            public void value(String value) {
+                assertEquals("\u00EB", value);
+                assertEquals("ë", value);
+            }
+            public void value(long value) {
+                fail();
+            }
+            public void value(double value) {
+                fail();
+            }
+            public void value(boolean value) {
+                fail();
+            }
+        };
+        JsonParser parser = new JsonParser(handler);
+        parser.parse(obj.toString());
+    }
+
+    public void testStringWithReturn() throws Exception {
+        ArrayList l = new ArrayList();
+        l.add("abc\ndef");
+        l.add("abc\rdef");
+        l.add("abc\n\rdef");
+        l.add("abc\tdef");
+        l.add("abc\bdef");
+        l.add("abc\n\\\tdef");
+        l.add("abc\f\u3456\b\\def");
+
+        for (Iterator it = l.iterator(); it.hasNext();) {
+            final String expValue = it.next().toString();
+            JSONObject obj = new JSONObject();
+            obj.put("string", expValue);
+
+            JsonHandler handler = new DummyJsonHandler() {
+                public void key(String key) {
+                    assertEquals("string", key);
+                }
+                public void value(String value) {
+                    assertEquals(expValue, value);
+                }
+            };
+            JsonParser parser = new JsonParser(handler);
+            parser.parse(obj.toString());
+        }
+    }
+
+    public void testNullValue() throws Exception {
+        JSONObject obj = new JSONObject();
+        obj.put("null", JSONObject.NULL);
+
+        JsonHandler handler = new DummyJsonHandler() {
+            public void key(String key) {
+                assertEquals("null", key);
+            }
+            public void value(String value) {
+                assertNull(value);
+            }
+        };
+        JsonParser parser = new JsonParser(handler);
+        parser.parse(obj.toString());
+    }
+
+    public void testArray() throws Exception {
+        JSONObject obj = new JSONObject();
+        obj.put("array", Arrays.asList(new String[] {"a", "b", "c"}));
+
+        JsonHandler handler = new DummyJsonHandler() {
+            boolean arrayStarted = false;
+            int index = 0;
+
+            public void key(String key) {
+                assertEquals("array", key);
+            }
+            public void array() {
+                assertFalse(arrayStarted);
+                arrayStarted = true;
+            }
+            public void endArray() {
+                assertTrue(arrayStarted);
+            }
+            public void value(long value) {
+                fail();
+            }
+            public void value(double value) {
+                fail();
+            }
+            public void value(boolean value) {
+                fail();
+            }
+            public void value(String value) {
+                assertTrue(arrayStarted);
+                switch (index) {
+                    case 0: assertEquals("a", value); break;
+                    case 1: assertEquals("b", value); break;
+                    case 2: assertEquals("c", value); break;
+                    default: fail();
+                }
+                index++;
+            }
+        };
+        JsonParser parser = new JsonParser(handler);
+        parser.parse(obj.toString());
+    }
+
+    public void testLongArray() throws Exception {
+        JSONObject obj = new JSONObject();
+        obj.put("longarray", Arrays.asList(new Long[] {new Long(123), new Long(3456), new Long(45367)}));
+
+        JsonHandler handler = new DummyJsonHandler() {
+            boolean arrayStarted = false;
+            int index = 0;
+
+            public void key(String key) {
+                assertEquals("longarray", key);
+            }
+            public void array() {
+                assertFalse(arrayStarted);
+                arrayStarted = true;
+            }
+            public void endArray() {
+                assertTrue(arrayStarted);
+            }
+            public void value(long value) {
+                assertTrue(arrayStarted);
+                switch (index) {
+                    case 0: assertEquals(123, value); break;
+                    case 1: assertEquals(3456, value); break;
+                    case 2: assertEquals(45367, value); break;
+                    default: fail();
+                }
+                index++;
+            }
+            public void value(double value) {
+                fail();
+            }
+            public void value(boolean value) {
+                fail();
+            }
+            public void value(String value) {
+                fail();
+            }
+        };
+        JsonParser parser = new JsonParser(handler);
+        parser.parse(obj.toString());
+    }
+
+    public void testParser2() throws Exception {
+        JSONObject obj = new JSONObject();
+        obj.put("obj1", getSimpleObj("bla"));
+        obj.put("obj2", getSimpleObj("blu"));
+        obj.put("obj3", getSimpleObj("bli"));
+
+        // TODO validate output. use specific handler ext.
+        JsonParser parser = new JsonParser(handler);
+        parser.parse(obj.toString());
+    }
+
+    public void testParser4() throws Exception {
+        JSONObject obj = new JSONObject();
+        obj.put("arr1", getSimpleArray(new String[] {"s", "t", "r"}));
+        obj.put("arr2", getSimpleArray(new String[] {"s", "t", "r"}));
+        obj.put("arr3", getSimpleArray(new String[] {"s", "t", "r"}));
+        obj.put("arr4", getSimpleArray(new String[] {"s", "t", "r"}));
+
+        // TODO validate output. use specific handler ext.        
+        JsonParser parser = new JsonParser(handler);
+        parser.parse(obj.toString());
+    }
+
+    public void testParser5() throws Exception {
+        JSONObject obj = new JSONObject();
+        obj.put("arr1", getSimpleArray(new JSONObject[] { getSimpleObj(new Integer(1)), getSimpleObj("abc"), getSimpleObj(Boolean.TRUE) }));
+        obj.put("objvalue", getSimpleObj( getSimpleArray(new Object[] {"a", new Double(2.3), Boolean.FALSE})));
+        obj.put("arrarr", getSimpleArray( new Object[] {getSimpleArray(new Object[] {"a", new Double(2.3), Boolean.FALSE})}));
+        obj.put("simplv", Boolean.TRUE);
+
+        // TODO validate output. use specific handler ext.        
+        JsonParser parser = new JsonParser(handler);
+        parser.parse(obj.toString());
+    }
+
+    public void testParser6() throws Exception {
+        final String expKey = "prop1";
+        final String expValue = "Any string containing comma, period. question mark?";
+
+        JsonHandler handler = new DummyJsonHandler() {
+            public void key(String key) {
+                assertEquals(expKey, key);
+            }
+
+            public void value(String value) {
+                assertEquals(expValue, value);
+            }
+        };
+
+        String str = "{\"" +expKey+ "\":\""+expValue+"\"}";
+
+        JsonParser parser = new JsonParser(handler);
+        parser.parse(str);
+    }
+
+    public void testParseEmptyObject() throws Exception {
+        JsonHandler handler = new DummyJsonHandler() {
+            private int objectCnt = 0;
+            public void object() {
+                objectCnt++;
+            }
+            public void endObject() {
+                assertEquals(1, objectCnt);
+            }
+            public void array() {
+                fail();
+            }
+            public void endArray() {
+                fail();
+            }
+            public void key(String key) {
+                fail();
+            }
+            public void value(String value) {
+                fail();
+            }
+            public void value(long value) {
+                fail();
+            }
+            public void value(double value) {
+                fail();
+            }
+            public void value(boolean value) {
+                fail();
+            }
+        };
+        JsonParser parser = new JsonParser(handler);
+        parser.parse("{}");
+    }
+
+    public void testParseEmptyObjectValue() throws Exception {
+
+        List l = new ArrayList();
+        l.add("{\"a\":{},\"b\":{},\"c\":{}}");
+        l.add("{\"a\":{\"b\":{\"c\":{}}}}");
+        l.add("{\"a\":{},\"b\":{\"c\":{}}}");
+        l.add("{\"a\":{\"b\":{},\"c\":{}}}");
+        
+        for (Iterator it = l.iterator(); it.hasNext();) {
+            JsonHandler handler = new DummyJsonHandler() {
+                private int objectCnt = 0;
+                public void object() {
+                    objectCnt++;
+                }
+                public void endObject() {
+                    assertFalse(objectCnt > 4);
+                }
+                public void array() {
+                    fail();
+                }
+                public void endArray() {
+                    fail();
+                }
+                public void value(String value) {
+                    fail();
+                }
+                public void value(long value) {
+                    fail();
+                }
+                public void value(double value) {
+                    fail();
+                }
+                public void value(boolean value) {
+                    fail();
+                }
+            };
+
+            JsonParser parser = new JsonParser(handler);
+            parser.parse(it.next().toString());
+        }
+    }
+    
+    private static JSONObject getObj() throws JSONException {
+        JSONObject obj = new JSONObject();
+        obj.put("boolean", true);
+        obj.put("long", 1);
+        obj.put("double", 1235674.342424);
+        obj.put("array", Arrays.asList(new String[] {"a", "b", "c"}));
+        obj.put("longarray", Arrays.asList(new Long[] {new Long(123), new Long(3456), new Long(45367)}));
+        obj.put("string", "abc");
+        obj.put("string1", "123.456");
+        return obj;
+    }
+
+    private static JSONObject getSimpleObj(Object value) throws JSONException {
+        JSONObject obj = new JSONObject();
+        obj.put("v", value);
+        return obj;
+    }
+
+    private static JSONArray getSimpleArray(Object[] values) throws JSONException {
+        JSONArray arr = new JSONArray();
+        for (int i = 0; i < values.length; i++) {
+            arr.put(values[i]);
+        }
+        return arr;
+    }
+
+    //--------------------------------------------------------------------------
+    /**
+     * Dummy handler impl that does nothing.
+     */
+    private class DummyJsonHandler implements JsonHandler {
+
+        public void object() {
+        }
+        public void endObject() {
+        }
+        public void array() {
+        }
+        public void endArray() {
+        }
+        public void key(String key) {
+        }
+        public void value(String value) {
+        }
+        public void value(long value) {
+        }
+        public void value(double value) {
+        }
+        public void value(boolean value) {
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonParserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonParserTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonUtilTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonUtilTest.java?rev=739210&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonUtilTest.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonUtilTest.java Fri Jan 30 09:04:39 2009
@@ -0,0 +1,56 @@
+/*
+ * 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.commons.json;
+
+import junit.framework.TestCase;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * <code>JSONUtilTest</code>...
+ */
+public class JsonUtilTest extends TestCase {
+
+    public void testGetJsonString() {
+        Map m = new HashMap();
+        m.put("abc", "\"abc\"");
+        m.put("a \"b\" c", "\"a \\\"b\\\" c\"");
+        m.put("a\tb\rc\nd\fe\b", "\"a\\tb\\rc\\nd\\fe\\b\"");
+        m.put("\\abc", "\"\\\\abc\"");
+        m.put("abc", "\"abc\"");
+
+        // non-printable ascii other than those treated (\t,\r,\n)
+        m.put(String.valueOf((char) 7), "\"\\u0007\"");
+        m.put(String.valueOf((char) 30), "\"\\u001e\"");
+
+        // chinese
+        m.put("\u4e00a\u4e8cb\u4e09c", "\"\u4e00a\u4e8cb\u4e09c\"");
+        /* arabic */
+        m.put("\u062c\u062f\u064a\u062f", "\"\u062c\u062f\u064a\u062f\"");
+        /* Ñaçb?c */
+        m.put("\u00d1a\u00e7b\u0416c", "\"\u00d1a\u00e7b\u0416c\"");
+        // âèøü
+        // m.put("âèøü", "\"\u00e2\u00e8\u00f8\u00fc\"");
+
+        for (Iterator it = m.keySet().iterator(); it.hasNext();) {
+            String key = it.next().toString();
+            assertEquals(m.get(key).toString(), JsonUtil.getJsonString(key));
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonUtilTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonUtilTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/TestAll.java?rev=739210&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/TestAll.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/TestAll.java Fri Jan 30 09:04:39 2009
@@ -0,0 +1,41 @@
+/*
+ * 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.commons.json;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Test suite that includes all testcases for package org.apache.jackrabbit.json.
+ */
+public class TestAll extends TestCase {
+
+    /**
+     * Returns a <code>Test</code> suite that executes all tests inside this
+     * package.
+     */
+    public static Test suite() {
+        
+        TestSuite suite = new TestSuite("org.apache.jackrabbit.json tests");
+
+        suite.addTestSuite(JsonUtilTest.class);
+        suite.addTestSuite(JsonParserTest.class);
+
+        return suite;
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/TestAll.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/TestAll.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/TextTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/TextTest.java?rev=739210&r1=739209&r2=739210&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/TextTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/TextTest.java Fri Jan 30 09:04:39 2009
@@ -154,33 +154,6 @@
         assertInvalidUnescape("%%");  // too short
         assertInvalidUnescape("%%%"); // not a number
     }
-
-    public void testGetJSONString() {
-        Map m = new HashMap();
-        m.put("abc", "\"abc\"");
-        m.put("a \"b\" c", "\"a \\\"b\\\" c\"");
-        m.put("a\tb\rc\nd\fe\b", "\"a\\tb\\rc\\nd\\fe\\b\"");
-        m.put("\\abc", "\"\\\\abc\"");
-        m.put("abc", "\"abc\"");
-
-        // non-printable ascii other than those treated (\t,\r,\n)
-        m.put(String.valueOf((char) 7), "\"\\u0007\"");
-        m.put(String.valueOf((char) 30), "\"\\u001e\"");
-
-        // chinese
-        m.put("\u4e00a\u4e8cb\u4e09c", "\"\u4e00a\u4e8cb\u4e09c\"");
-        /* arabic */
-        m.put("\u062c\u062f\u064a\u062f", "\"\u062c\u062f\u064a\u062f\"");
-        /* Ñaçb?c */
-        m.put("\u00d1a\u00e7b\u0416c", "\"\u00d1a\u00e7b\u0416c\"");
-        // âèøü
-        // m.put("âèøü", "\"\u00e2\u00e8\u00f8\u00fc\"");
-
-        for (Iterator it = m.keySet().iterator(); it.hasNext();) {
-            String key = it.next().toString();
-            assertEquals(m.get(key).toString(), Text.getJSONString(key));
-        }
-    }
     
     private void assertInvalidUnescape(String string) {
         try {

Modified: jackrabbit/trunk/jackrabbit-parent/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-parent/pom.xml?rev=739210&r1=739209&r2=739210&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-parent/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-parent/pom.xml Fri Jan 30 09:04:39 2009
@@ -760,6 +760,11 @@
         <scope>provided</scope>
       </dependency>
       <dependency>
+        <groupId>commons-fileupload</groupId>
+        <artifactId>commons-fileupload</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
         <groupId>org.mortbay.jetty</groupId>
         <artifactId>jetty</artifactId>
         <version>${jetty.version}</version>
@@ -800,6 +805,11 @@
         <version>1.1</version>
       </dependency>
       <dependency>
+        <groupId>org.json</groupId>
+        <artifactId>json</artifactId>
+        <version>20070829</version>
+      </dependency>
+      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>3.8.1</version>