chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1004660 - in /incubator/chemistry/opencmis-browser-binding/trunk: ./ src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/ src/main/webapp/ src/main/webapp/WE...
Date Tue, 05 Oct 2010 14:55:56 GMT
Author: fmui
Date: Tue Oct  5 14:55:55 2010
New Revision: 1004660

URL: http://svn.apache.org/viewvc?rev=1004660&view=rev
Log:
- reworked browser binding framework

Added:
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java   (with props)
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java   (with props)
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/NavigationService.java   (with props)
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java   (with props)
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java   (with props)
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.html   (with props)
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.html   (with props)
Removed:
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisApplication.java
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisJaxbContextResolver.java
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisResource.java
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.jsp
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.jsp
Modified:
    incubator/chemistry/opencmis-browser-binding/trunk/pom.xml
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConstants.java
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/WEB-INF/web.xml

Modified: incubator/chemistry/opencmis-browser-binding/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/pom.xml?rev=1004660&r1=1004659&r2=1004660&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/pom.xml (original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/pom.xml Tue Oct  5 14:55:55 2010
@@ -92,16 +92,6 @@
             <version>0.2.0-incubating-SNAPSHOT</version>
         </dependency>
         <dependency>
-             <groupId>com.sun.jersey</groupId>
-             <artifactId>jersey-server</artifactId>
-             <version>1.3</version>
-        </dependency>
-        <dependency>
-             <groupId>com.sun.jersey</groupId>
-             <artifactId>jersey-json</artifactId>
-             <version>1.3</version>
-        </dependency>
-        <dependency>
              <groupId>com.googlecode.json-simple</groupId>
              <artifactId>json-simple</artifactId>
              <version>1.1</version>
@@ -114,18 +104,4 @@
         </dependency>
     </dependencies>
 
-    <repositories>
-        <repository>
-            <id>maven-repository.dev.java.net</id>
-            <name>Java.net Repository for Maven 1</name>
-            <url>http://download.java.net/maven/1/</url>
-            <layout>legacy</layout>
-        </repository>
-        <repository>
-            <id>maven2-repository.dev.java.net</id>
-            <name>Java.net Repository for Maven 2</name>
-            <url>http://download.java.net/maven/2/</url>
-        </repository>
-    </repositories>
-
 </project>

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java?rev=1004660&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java Tue Oct  5 14:55:55 2010
@@ -0,0 +1,177 @@
+/*
+ * 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.chemistry.opencmis.server.impl.browser;
+
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.data.ObjectData;
+import org.apache.chemistry.opencmis.commons.data.Properties;
+import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.commons.impl.Constants;
+import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
+import org.apache.chemistry.opencmis.commons.server.CallContext;
+import org.apache.chemistry.opencmis.commons.server.CmisService;
+import org.apache.chemistry.opencmis.server.impl.CallContextImpl;
+import org.apache.chemistry.opencmis.server.shared.HttpUtils;
+import org.json.simple.JSONStreamAware;
+
+public class BrowserBindingUtils {
+
+    public static final String JSON_MIME_TYPE = "application/json";
+
+    public static final String METHOD_GET_CONTENT = "getContentStream";
+    public static final String METHOD_GET_OBJECT = "getObject";
+    public static final String METHOD_GET_CHILDREN = "getChildren";
+
+    public static final String PARAM_METHOD = "method";
+    public static final String PARAM_CALLBACK = "callback";
+    public static final String PARAM_INCLUDE_TYPE = "includeTypeInformation";
+
+    public static final String CONTEXT_OBJECT_ID = "org.apache.chemistry.openmis.browserbinding.objectId";
+    public static final String CONTEXT_BASETYPE_ID = "org.apache.chemistry.openmis.browserbinding.basetypeId";
+
+    /**
+     * Compiles the base URL for links, collections and templates.
+     */
+    public static UrlBuilder compileBaseUrl(HttpServletRequest request, String repositoryId) {
+        UrlBuilder url = new UrlBuilder(request.getScheme(), request.getServerName(), request.getServerPort(), null);
+
+        url.addPath(request.getContextPath());
+        url.addPath(request.getServletPath());
+
+        if (repositoryId != null) {
+            url.addPathSegment(repositoryId);
+        }
+
+        return url;
+    }
+
+    /**
+     * Returns the current CMIS path.
+     */
+    public static String getPath(HttpServletRequest request) {
+        String[] pathFragments = HttpUtils.splitPath(request);
+        if (pathFragments.length < 1) {
+            return null;
+        }
+        if (pathFragments.length == 1) {
+            return "/";
+        }
+
+        StringBuilder sb = new StringBuilder();
+        for (int i = 1; i < pathFragments.length; i++) {
+            if (pathFragments[i].length() == 0) {
+                continue;
+            }
+
+            sb.append("/");
+            sb.append(pathFragments[i]);
+        }
+
+        return sb.toString();
+    }
+
+    /**
+     * Returns the object id of the current request.
+     */
+    public static void prepareContext(CallContext context, CmisService service, String repositoryId,
+            HttpServletRequest request) {
+        ObjectData object = null;
+
+        String objectId = getStringParameter(request, Constants.PARAM_OBJECT_ID);
+        if (objectId != null) {
+            object = service.getObject(repositoryId, objectId, null, false, IncludeRelationships.NONE, "cmis:none",
+                    false, false, null);
+        } else {
+            object = service.getObjectByPath(repositoryId, getPath(request), null, false, IncludeRelationships.NONE,
+                    "cmis:none", false, false, null);
+        }
+
+        if (context instanceof CallContextImpl) {
+            ((CallContextImpl) context).put(CONTEXT_OBJECT_ID, object.getId());
+            ((CallContextImpl) context).put(CONTEXT_BASETYPE_ID,
+                    getProperty(object, PropertyIds.BASE_TYPE_ID, String.class));
+        }
+    }
+
+    /**
+     * Extracts a property from an object.
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> T getProperty(ObjectData object, String name, Class<T> clazz) {
+        if (object == null) {
+            return null;
+        }
+
+        Properties propData = object.getProperties();
+        if (propData == null) {
+            return null;
+        }
+
+        Map<String, PropertyData<?>> properties = propData.getProperties();
+        if (properties == null) {
+            return null;
+        }
+
+        PropertyData<?> property = properties.get(name);
+        if (property == null) {
+            return null;
+        }
+
+        Object value = property.getFirstValue();
+        if (!clazz.isInstance(value)) {
+            return null;
+        }
+
+        return (T) value;
+    }
+
+    /**
+     * Writes JSON to the servlet response and adds a callback wrapper if
+     * requested.
+     */
+    public static void writeJSON(JSONStreamAware json, HttpServletRequest request, HttpServletResponse response)
+            throws IOException {
+        response.setContentType(JSON_MIME_TYPE);
+        response.setCharacterEncoding("UTF-8");
+
+        String callback = getStringParameter(request, PARAM_CALLBACK);
+        if (callback != null) {
+            if (!callback.matches("[A-Za-z0-9._\\[\\]]*")) {
+                throw new CmisInvalidArgumentException("Invalid callback name!");
+            }
+            response.getWriter().print(callback + "(");
+        }
+
+        json.writeJSONString(response.getWriter());
+
+        if (callback != null) {
+            response.getWriter().print(");");
+        }
+    }
+}

Propchange: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java?rev=1004660&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java Tue Oct  5 14:55:55 2010
@@ -0,0 +1,248 @@
+/*
+ * 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.chemistry.opencmis.server.impl.browser;
+
+import java.io.IOException;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisFilterNotValidException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisNameConstraintViolationException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisStorageException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisStreamNotSupportedException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisVersioningException;
+import org.apache.chemistry.opencmis.commons.server.CallContext;
+import org.apache.chemistry.opencmis.commons.server.CmisService;
+import org.apache.chemistry.opencmis.commons.server.CmisServiceFactory;
+import org.apache.chemistry.opencmis.server.impl.CmisRepositoryContextListener;
+import org.apache.chemistry.opencmis.server.impl.browser.json.JSONConstants;
+import org.apache.chemistry.opencmis.server.shared.CallContextHandler;
+import org.apache.chemistry.opencmis.server.shared.Dispatcher;
+import org.apache.chemistry.opencmis.server.shared.HttpUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.json.simple.JSONObject;
+
+public class CmisBrowserBindingServlet extends HttpServlet {
+
+    private static final long serialVersionUID = 1L;
+
+    public static final String PARAM_CALL_CONTEXT_HANDLER = "callContextHandler";
+
+    private static final Log LOG = LogFactory.getLog(CmisBrowserBindingServlet.class.getName());
+
+    private Dispatcher dispatcher;
+    private CallContextHandler callContextHandler;
+
+    @Override
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+
+        // initialize the call context handler
+        callContextHandler = null;
+        String callContextHandlerClass = config.getInitParameter(PARAM_CALL_CONTEXT_HANDLER);
+        if (callContextHandlerClass != null) {
+            try {
+                callContextHandler = (CallContextHandler) Class.forName(callContextHandlerClass).newInstance();
+            } catch (Exception e) {
+                throw new ServletException("Could not load call context handler: " + e, e);
+            }
+        }
+
+        // initialize the dispatcher
+        dispatcher = new Dispatcher();
+
+        try {
+            dispatcher.addResource(BrowserBindingUtils.METHOD_GET_OBJECT, Dispatcher.METHOD_GET, ObjectService.class,
+                    "getObject");
+            dispatcher.addResource(BrowserBindingUtils.METHOD_GET_CONTENT, Dispatcher.METHOD_GET, ObjectService.class,
+                    "getContentStream");
+            dispatcher.addResource(BrowserBindingUtils.METHOD_GET_CHILDREN, Dispatcher.METHOD_GET,
+                    NavigationService.class, "getChildren");
+        } catch (NoSuchMethodException e) {
+            LOG.error("Cannot initialize dispatcher!", e);
+        }
+
+    }
+
+    @Override
+    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException,
+            IOException {
+
+        // create a context object, dispatch and handle exceptions
+        CallContext context = null;
+        try {
+            context = HttpUtils.createContext(request, CallContext.BINDING_BROWSER, callContextHandler);
+            dispatch(context, request, response);
+        } catch (Exception e) {
+            if (e instanceof CmisPermissionDeniedException) {
+                if ((context == null) || (context.getUsername() == null)) {
+                    response.setHeader("WWW-Authenticate", "Basic realm=\"CMIS\"");
+                    response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authorization Required");
+                } else {
+                    writeError((CmisBaseException) e, request, response);
+                }
+            } else if (e instanceof CmisRuntimeException) {
+                LOG.error(e.getMessage(), e);
+                writeError((CmisBaseException) e, request, response);
+            } else if (e instanceof CmisBaseException) {
+                writeError((CmisBaseException) e, request, response);
+            } else {
+                LOG.error(e.getMessage(), e);
+                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
+            }
+        }
+
+        // we are done.
+        response.flushBuffer();
+    }
+
+    // --------------------------------------------------------
+
+    private void dispatch(CallContext context, HttpServletRequest request, HttpServletResponse response)
+            throws Exception {
+        CmisService service = null;
+        try {
+            // get services factory
+            CmisServiceFactory factory = (CmisServiceFactory) getServletContext().getAttribute(
+                    CmisRepositoryContextListener.SERVICES_FACTORY);
+
+            if (factory == null) {
+                throw new CmisRuntimeException("Service factory not available! Configuration problem?");
+            }
+
+            // get the service
+            service = factory.getService(context);
+
+            // analyze the path
+            String[] pathFragments = HttpUtils.splitPath(request);
+
+            if (pathFragments.length < 1) {
+                // root -> repository infos
+                RepositoryService.getRepositories(context, service, request, response);
+                return;
+            }
+
+            String method = request.getMethod();
+            String repositoryId = pathFragments[0];
+
+            String resource = HttpUtils.getStringParameter(request, BrowserBindingUtils.PARAM_METHOD);
+
+            // add object id and object base type id to context
+            BrowserBindingUtils.prepareContext(context, service, repositoryId, request);
+
+            // set default method if necessary
+            if (resource == null) {
+                try {
+                    BaseTypeId basetype = BaseTypeId.fromValue(context.get(BrowserBindingUtils.CONTEXT_BASETYPE_ID));
+                    switch (basetype) {
+                    case CMIS_DOCUMENT:
+                        resource = BrowserBindingUtils.METHOD_GET_CONTENT;
+                        break;
+                    case CMIS_FOLDER:
+                        resource = BrowserBindingUtils.METHOD_GET_CHILDREN;
+                        break;
+                    default:
+                        resource = BrowserBindingUtils.METHOD_GET_OBJECT;
+                        break;
+                    }
+                } catch (Exception e) {
+                    resource = BrowserBindingUtils.METHOD_GET_OBJECT;
+                }
+            }
+
+            // dispatch
+            boolean methodFound = dispatcher.dispatch(resource, method, context, service, repositoryId, request,
+                    response);
+
+            // if the dispatcher couldn't find a matching method, return an
+            // error message
+            if (!methodFound) {
+                throw new CmisNotSupportedException("Unknown operation");
+            }
+        } finally {
+            if (service != null) {
+                service.close();
+            }
+        }
+    }
+
+    /**
+     * Translates an exception in an appropriate HTTP error code.
+     */
+    @SuppressWarnings("unchecked")
+    private void writeError(CmisBaseException ex, HttpServletRequest request, HttpServletResponse response) {
+        int code = 500;
+
+        if (ex instanceof CmisConstraintException) {
+            code = 409;
+        } else if (ex instanceof CmisContentAlreadyExistsException) {
+            code = 409;
+        } else if (ex instanceof CmisFilterNotValidException) {
+            code = 400;
+        } else if (ex instanceof CmisInvalidArgumentException) {
+            code = 400;
+        } else if (ex instanceof CmisNameConstraintViolationException) {
+            code = 409;
+        } else if (ex instanceof CmisNotSupportedException) {
+            code = 405;
+        } else if (ex instanceof CmisObjectNotFoundException) {
+            code = 404;
+        } else if (ex instanceof CmisPermissionDeniedException) {
+            code = 403;
+        } else if (ex instanceof CmisStorageException) {
+            code = 500;
+        } else if (ex instanceof CmisStreamNotSupportedException) {
+            code = 403;
+        } else if (ex instanceof CmisUpdateConflictException) {
+            code = 409;
+        } else if (ex instanceof CmisVersioningException) {
+            code = 409;
+        }
+
+        response.setStatus(code);
+        response.setContentType(BrowserBindingUtils.JSON_MIME_TYPE);
+
+        JSONObject jsonResponse = new JSONObject();
+        JSONObject jsonResponseObject = new JSONObject();
+        jsonResponse.put(JSONConstants.ERROR_INFO, jsonResponseObject);
+        jsonResponseObject.put(JSONConstants.ERROR_CODE, code);
+        jsonResponseObject.put(JSONConstants.ERROR_MESSAGE, ex.getMessage());
+
+        try {
+            BrowserBindingUtils.writeJSON(jsonResponse, request, response);
+        } catch (Exception e) {
+            LOG.error(e.getMessage(), e);
+        }
+    }
+}

Propchange: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/NavigationService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/NavigationService.java?rev=1004660&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/NavigationService.java (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/NavigationService.java Tue Oct  5 14:55:55 2010
@@ -0,0 +1,72 @@
+/*
+ * 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.chemistry.opencmis.server.impl.browser;
+
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBigIntegerParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBooleanParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getEnumParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
+
+import java.math.BigInteger;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
+import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.chemistry.opencmis.commons.impl.Constants;
+import org.apache.chemistry.opencmis.commons.server.CallContext;
+import org.apache.chemistry.opencmis.commons.server.CmisService;
+import org.apache.chemistry.opencmis.server.impl.browser.json.JSONConverter;
+import org.json.simple.JSONObject;
+
+public final class NavigationService {
+
+    /**
+     * Children Collection GET.
+     */
+    public static void getChildren(CallContext context, CmisService service, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        // get parameters
+        String folderId = context.get(BrowserBindingUtils.CONTEXT_OBJECT_ID);
+        String filter = getStringParameter(request, Constants.PARAM_FILTER);
+        String orderBy = getStringParameter(request, Constants.PARAM_ORDER_BY);
+        Boolean includeAllowableActions = getBooleanParameter(request, Constants.PARAM_ALLOWABLE_ACTIONS);
+        IncludeRelationships includeRelationships = getEnumParameter(request, Constants.PARAM_RELATIONSHIPS,
+                IncludeRelationships.class);
+        String renditionFilter = getStringParameter(request, Constants.PARAM_RENDITION_FILTER);
+        Boolean includePathSegment = getBooleanParameter(request, Constants.PARAM_PATH_SEGMENT);
+        BigInteger maxItems = getBigIntegerParameter(request, Constants.PARAM_MAX_ITEMS);
+        BigInteger skipCount = getBigIntegerParameter(request, Constants.PARAM_SKIP_COUNT);
+
+        // execute
+        ObjectInFolderList children = service.getChildren(repositoryId, folderId, filter, orderBy,
+                includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, maxItems,
+                skipCount, null);
+
+        if (children == null) {
+            throw new CmisRuntimeException("Children are null!");
+        }
+
+        JSONObject jsonChildren = JSONConverter.convert(children);
+
+        BrowserBindingUtils.writeJSON(jsonChildren, request, response);
+    }
+}

Propchange: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/NavigationService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java?rev=1004660&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java Tue Oct  5 14:55:55 2010
@@ -0,0 +1,140 @@
+/*
+ * 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.chemistry.opencmis.server.impl.browser;
+
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBooleanParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getEnumParameter;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.math.BigInteger;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.data.ObjectData;
+import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.chemistry.opencmis.commons.impl.Constants;
+import org.apache.chemistry.opencmis.commons.impl.ReturnVersion;
+import org.apache.chemistry.opencmis.commons.server.CallContext;
+import org.apache.chemistry.opencmis.commons.server.CmisService;
+import org.apache.chemistry.opencmis.server.impl.browser.json.JSONConverter;
+import org.json.simple.JSONObject;
+
+public final class ObjectService {
+
+    private static final int BUFFER_SIZE = 64 * 1024;
+
+    /**
+     * getObject.
+     */
+    public static void getObject(CallContext context, CmisService service, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        // get parameters
+        String objectId = context.get(BrowserBindingUtils.CONTEXT_OBJECT_ID);
+        ReturnVersion returnVersion = getEnumParameter(request, Constants.PARAM_RETURN_VERSION, ReturnVersion.class);
+        String filter = getStringParameter(request, Constants.PARAM_FILTER);
+        Boolean includeAllowableActions = getBooleanParameter(request, Constants.PARAM_ALLOWABLE_ACTIONS);
+        IncludeRelationships includeRelationships = getEnumParameter(request, Constants.PARAM_RELATIONSHIPS,
+                IncludeRelationships.class);
+        String renditionFilter = getStringParameter(request, Constants.PARAM_RENDITION_FILTER);
+        Boolean includePolicyIds = getBooleanParameter(request, Constants.PARAM_POLICY_IDS);
+        Boolean includeAcl = getBooleanParameter(request, Constants.PARAM_ACL);
+
+        // execute
+        ObjectData object = null;
+
+        if ((returnVersion == ReturnVersion.LATEST) || (returnVersion == ReturnVersion.LASTESTMAJOR)) {
+            object = service.getObjectOfLatestVersion(repositoryId, objectId, null,
+                    returnVersion == ReturnVersion.LASTESTMAJOR, filter, includeAllowableActions, includeRelationships,
+                    renditionFilter, includePolicyIds, includeAcl, null);
+        } else {
+            object = service.getObject(repositoryId, objectId, filter, includeAllowableActions, includeRelationships,
+                    renditionFilter, includePolicyIds, includeAcl, null);
+        }
+
+        if (object == null) {
+            throw new CmisRuntimeException("Object is null!");
+        }
+
+        JSONObject jsonObject = JSONConverter.convert(object);
+
+        BrowserBindingUtils.writeJSON(jsonObject, request, response);
+    }
+
+    /**
+     * getContentStream.
+     */
+    public static void getContentStream(CallContext context, CmisService service, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        // get parameters
+        String objectId = context.get(BrowserBindingUtils.CONTEXT_OBJECT_ID);
+        String streamId = getStringParameter(request, Constants.PARAM_STREAM_ID);
+
+        BigInteger offset = null;
+        String offsetStr = context.get(CallContext.OFFSET);
+        if (offsetStr != null) {
+            offset = new BigInteger(offsetStr);
+        }
+
+        BigInteger length = null;
+        String lengthStr = context.get(CallContext.LENGTH);
+        if (lengthStr != null) {
+            length = new BigInteger(offsetStr);
+        }
+
+        // execute
+        ContentStream content = service.getContentStream(repositoryId, objectId, streamId, offset, length, null);
+
+        if ((content == null) || (content.getStream() == null)) {
+            throw new CmisRuntimeException("Content stream is null!");
+        }
+
+        String contentType = content.getMimeType();
+        if (contentType == null) {
+            contentType = Constants.MEDIATYPE_OCTETSTREAM;
+        }
+
+        // set headers
+        if ((offset == null) && (length == null)) {
+            response.setStatus(HttpServletResponse.SC_OK);
+        } else {
+            response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
+        }
+        response.setContentType(contentType);
+
+        // send content
+        InputStream in = new BufferedInputStream(content.getStream(), BUFFER_SIZE);
+        OutputStream out = new BufferedOutputStream(response.getOutputStream());
+
+        byte[] buffer = new byte[BUFFER_SIZE];
+        int b;
+        while ((b = in.read(buffer)) > -1) {
+            out.write(buffer, 0, b);
+        }
+
+        in.close();
+        out.flush();
+    }
+}

Propchange: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java?rev=1004660&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java Tue Oct  5 14:55:55 2010
@@ -0,0 +1,66 @@
+/*
+ * 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.chemistry.opencmis.server.impl.browser;
+
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+import org.apache.chemistry.opencmis.commons.impl.Constants;
+import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
+import org.apache.chemistry.opencmis.commons.server.CallContext;
+import org.apache.chemistry.opencmis.commons.server.CmisService;
+import org.apache.chemistry.opencmis.server.impl.CallContextImpl;
+import org.apache.chemistry.opencmis.server.impl.browser.json.JSONConverter;
+import org.json.simple.JSONObject;
+
+public final class RepositoryService {
+
+    @SuppressWarnings("unchecked")
+    public static void getRepositories(CallContext context, CmisService service, HttpServletRequest request,
+            HttpServletResponse response) throws Exception {
+        // get parameters
+        String repositoryId = getStringParameter(request, Constants.PARAM_REPOSITORY_ID);
+
+        // execute
+        List<RepositoryInfo> infoDataList = null;
+        if (repositoryId == null) {
+            infoDataList = service.getRepositoryInfos(null);
+        } else {
+            infoDataList = Collections.singletonList(service.getRepositoryInfo(repositoryId, null));
+            if (context instanceof CallContextImpl) {
+                ((CallContextImpl) context).put(CallContext.REPOSITORY_ID, repositoryId);
+            }
+        }
+
+        UrlBuilder baseUrl = BrowserBindingUtils.compileBaseUrl(request, null);
+
+        JSONObject result = new JSONObject();
+        for (RepositoryInfo ri : infoDataList) {
+            result.put(ri.getId(), JSONConverter.convert(ri, baseUrl));
+        }
+
+        BrowserBindingUtils.writeJSON(result, request, response);
+    }
+}

Propchange: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConstants.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConstants.java?rev=1004660&r1=1004659&r2=1004660&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConstants.java (original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConstants.java Tue Oct  5 14:55:55 2010
@@ -20,22 +20,27 @@ package org.apache.chemistry.opencmis.se
 
 public class JSONConstants {
 
-    public final static String JSON_REPINFO_ID = "repositoryId";
-    public final static String JSON_REPINFO_NAME = "repositoryName";
-    public final static String JSON_REPINFO_DESCRIPTION = "repositoryDescription";
-    public final static String JSON_REPINFO_VENDOR = "vendorName";
-    public final static String JSON_REPINFO_PRODUCT = "productName";
-    public final static String JSON_REPINFO_PRODUCT_VERSION = "productVersion";
-    public final static String JSON_REPINFO_ROOT_FOLDER_ID = "rootFolderId";
-    public final static String JSON_REPINFO_CAPABILITIES = "capabilities";
-    public final static String JSON_REPINFO_ACL_CAPABILITIES = "aclCapabilities";
-    public final static String JSON_REPINFO_CHANGE_LOCK_TOKEN = "latestChangeLogToken";
-    public final static String JSON_REPINFO_CMIS_VERSION_SUPPORTED = "cmisVersionSupported";
-    public final static String JSON_REPINFO_THIN_CLIENT_URI = "thinClientURI";
-    public final static String JSON_REPINFO_CHANGES_INCOMPLETE = "changesIncomplete";
-    public final static String JSON_REPINFO_CHANGES_ON_TYPE = "changesOnType";
-    public final static String JSON_REPINFO_PRINCIPAL_ID_ANONYMOUS = "principalIdAnonymous";
-    public final static String JSON_REPINFO_PRINCIPAL_ID_ANYONE = "principalIdAnyone";
+    public final static String ERROR_INFO = "responseInfo";
+    public final static String ERROR_CODE = "statusCode";
+    public final static String ERROR_MESSAGE = "message";
+
+    public final static String REPINFO_ID = "repositoryId";
+    public final static String REPINFO_NAME = "repositoryName";
+    public final static String REPINFO_DESCRIPTION = "repositoryDescription";
+    public final static String REPINFO_VENDOR = "vendorName";
+    public final static String REPINFO_PRODUCT = "productName";
+    public final static String REPINFO_PRODUCT_VERSION = "productVersion";
+    public final static String REPINFO_ROOT_FOLDER_ID = "rootFolderId";
+    public final static String REPINFO_ROOT_FOLDER_URL = "rootFolderUrl";
+    public final static String REPINFO_CAPABILITIES = "capabilities";
+    public final static String REPINFO_ACL_CAPABILITIES = "aclCapabilities";
+    public final static String REPINFO_CHANGE_LOCK_TOKEN = "latestChangeLogToken";
+    public final static String REPINFO_CMIS_VERSION_SUPPORTED = "cmisVersionSupported";
+    public final static String REPINFO_THIN_CLIENT_URI = "thinClientURI";
+    public final static String REPINFO_CHANGES_INCOMPLETE = "changesIncomplete";
+    public final static String REPINFO_CHANGES_ON_TYPE = "changesOnType";
+    public final static String REPINFO_PRINCIPAL_ID_ANONYMOUS = "principalIdAnonymous";
+    public final static String REPINFO_PRINCIPAL_ID_ANYONE = "principalIdAnyone";
 
     public final static String JSON_CAP_CONTENT_STREAM_UPDATES = "contentStreamUpdates";
     public final static String JSON_CAP_CHANGES = "changes";

Modified: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java?rev=1004660&r1=1004659&r2=1004660&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java (original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java Tue Oct  5 14:55:55 2010
@@ -46,6 +46,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.Action;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.enums.PropertyType;
+import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
 import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 
@@ -61,26 +62,30 @@ public class JSONConverter extends JSONC
      * Converts a repository info object.
      */
     @SuppressWarnings("unchecked")
-    public static JSONObject convert(RepositoryInfo repositoryInfo) {
+    public static JSONObject convert(RepositoryInfo repositoryInfo, UrlBuilder baseUrl) {
         if (repositoryInfo == null) {
             return null;
         }
 
+        UrlBuilder repUrl = new UrlBuilder(baseUrl);
+        repUrl.addPathSegment(repositoryInfo.getId());
+
         JSONObject result = new JSONObject();
 
-        result.put(JSON_REPINFO_ID, repositoryInfo.getId());
-        result.put(JSON_REPINFO_NAME, repositoryInfo.getName());
-        result.put(JSON_REPINFO_DESCRIPTION, repositoryInfo.getDescription());
-        result.put(JSON_REPINFO_VENDOR, repositoryInfo.getVendorName());
-        result.put(JSON_REPINFO_PRODUCT, repositoryInfo.getProductName());
-        result.put(JSON_REPINFO_PRODUCT_VERSION, repositoryInfo.getProductVersion());
-        result.put(JSON_REPINFO_ROOT_FOLDER_ID, repositoryInfo.getRootFolderId());
-        result.put(JSON_REPINFO_CAPABILITIES, convert(repositoryInfo.getCapabilities()));
-        result.put(JSON_REPINFO_ACL_CAPABILITIES, convert(repositoryInfo.getAclCapabilities()));
-        result.put(JSON_REPINFO_CHANGE_LOCK_TOKEN, repositoryInfo.getLatestChangeLogToken());
-        result.put(JSON_REPINFO_CMIS_VERSION_SUPPORTED, repositoryInfo.getCmisVersionSupported());
-        result.put(JSON_REPINFO_THIN_CLIENT_URI, repositoryInfo.getThinClientUri());
-        result.put(JSON_REPINFO_CHANGES_INCOMPLETE, repositoryInfo.getChangesIncomplete());
+        result.put(REPINFO_ID, repositoryInfo.getId());
+        result.put(REPINFO_NAME, repositoryInfo.getName());
+        result.put(REPINFO_DESCRIPTION, repositoryInfo.getDescription());
+        result.put(REPINFO_VENDOR, repositoryInfo.getVendorName());
+        result.put(REPINFO_PRODUCT, repositoryInfo.getProductName());
+        result.put(REPINFO_PRODUCT_VERSION, repositoryInfo.getProductVersion());
+        result.put(REPINFO_ROOT_FOLDER_ID, repositoryInfo.getRootFolderId());
+        result.put(REPINFO_ROOT_FOLDER_URL, (new UrlBuilder(repUrl)).toString());
+        result.put(REPINFO_CAPABILITIES, convert(repositoryInfo.getCapabilities()));
+        result.put(REPINFO_ACL_CAPABILITIES, convert(repositoryInfo.getAclCapabilities()));
+        result.put(REPINFO_CHANGE_LOCK_TOKEN, repositoryInfo.getLatestChangeLogToken());
+        result.put(REPINFO_CMIS_VERSION_SUPPORTED, repositoryInfo.getCmisVersionSupported());
+        result.put(REPINFO_THIN_CLIENT_URI, repositoryInfo.getThinClientUri());
+        result.put(REPINFO_CHANGES_INCOMPLETE, repositoryInfo.getChangesIncomplete());
 
         if (repositoryInfo.getChangesOnType() != null) {
             JSONArray changesOnType = new JSONArray();
@@ -89,11 +94,11 @@ public class JSONConverter extends JSONC
                 changesOnType.add(getJSONStringValue(type));
             }
 
-            result.put(JSON_REPINFO_CHANGES_ON_TYPE, changesOnType);
+            result.put(REPINFO_CHANGES_ON_TYPE, changesOnType);
         }
 
-        result.put(JSON_REPINFO_PRINCIPAL_ID_ANONYMOUS, repositoryInfo.getPrincipalIdAnonymous());
-        result.put(JSON_REPINFO_PRINCIPAL_ID_ANYONE, repositoryInfo.getPrincipalIdAnyone());
+        result.put(REPINFO_PRINCIPAL_ID_ANONYMOUS, repositoryInfo.getPrincipalIdAnonymous());
+        result.put(REPINFO_PRINCIPAL_ID_ANYONE, repositoryInfo.getPrincipalIdAnyone());
 
         return result;
     }
@@ -199,22 +204,19 @@ public class JSONConverter extends JSONC
             JSONObject properties = new JSONObject();
 
             for (PropertyData<?> prop : object.getProperties().getPropertyList()) {
-                JSONArray propertyValues = new JSONArray();
-                if (prop.getValues() != null) {
+                if (prop.getValues() == null) {
+                    properties.put(prop.getId(), null);
+                } else if (prop.getValues().size() == 1) {
+                    properties.put(prop.getId(), getJSONValue(prop.getValues().get(0)));
+                } else {
+                    JSONArray values = new JSONArray();
+
                     for (Object value : prop.getValues()) {
-                        propertyValues.add(getJSONValue(value));
+                        values.add(getJSONValue(value));
                     }
-                }
 
-                JSONObject propertyObject = new JSONObject();
-                propertyObject.put(JSON_PROPERTY_ID, prop.getId());
-                propertyObject.put(JSON_PROPERTY_LOCAL_NAME, prop.getLocalName());
-                propertyObject.put(JSON_PROPERTY_DISPLAY_NAME, prop.getDisplayName());
-                propertyObject.put(JSON_PROPERTY_QUERY_NAME, prop.getQueryName());
-                propertyObject.put(JSON_PROPERTY_VALUES, propertyValues);
-                propertyObject.put(JSON_PROPERTY_DATATYPE, getJSONPropertyDataType(prop));
-
-                properties.put(prop.getId(), propertyObject);
+                    properties.put(prop.getId(), values);
+                }
             }
 
             result.put(JSON_OBJECT_PROPERTIES, properties);
@@ -380,10 +382,10 @@ public class JSONConverter extends JSONC
         JSONObject result = new JSONObject();
 
         if (objectInFolderList.getObjects() != null) {
-            JSONArray objects = new JSONArray();
+            JSONObject objects = new JSONObject();
 
             for (ObjectInFolderData object : objectInFolderList.getObjects()) {
-                objects.add(convert(object));
+                objects.put(object.getObject().getId(), convert(object));
             }
 
             result.put(JSON_OBJECTINFOLDERLIST_OBJECTS, objects);

Modified: incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/WEB-INF/web.xml?rev=1004660&r1=1004659&r2=1004660&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/WEB-INF/web.xml (original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/WEB-INF/web.xml Tue Oct  5 14:55:55 2010
@@ -24,7 +24,7 @@
 	<display-name>OpenCMIS Server</display-name>
 
 	<welcome-file-list>
-		<welcome-file>index.jsp</welcome-file>
+		<welcome-file>index.html</welcome-file>
 	</welcome-file-list>
 
 	<listener>
@@ -46,18 +46,19 @@
 		<servlet-class>org.apache.chemistry.opencmis.server.impl.atompub.CmisAtomPubServlet</servlet-class>
 		<init-param>
 			<param-name>callContextHandler</param-name>
-			<param-value>org.apache.chemistry.opencmis.server.impl.atompub.BasicAuthCallContextHandler</param-value>
+			<param-value>org.apache.chemistry.opencmis.server.shared.BasicAuthCallContextHandler</param-value>
 		</init-param>
 		<load-on-startup>2</load-on-startup>
 	</servlet>
 
 	<servlet>
 		<servlet-name>cmisbrowser</servlet-name>
-		<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
+		<servlet-class>org.apache.chemistry.opencmis.server.impl.browser.CmisBrowserBindingServlet</servlet-class>
 		<init-param>
-			<param-name>javax.ws.rs.Application</param-name>
-			<param-value>org.apache.chemistry.opencmis.server.impl.browser.CmisApplication</param-value>
+			<param-name>callContextHandler</param-name>
+			<param-value>org.apache.chemistry.opencmis.server.shared.BasicAuthCallContextHandler</param-value>
 		</init-param>
+		<load-on-startup>2</load-on-startup>
 	</servlet>
 
 	<servlet-mapping>

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.html
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.html?rev=1004660&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.html (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.html Tue Oct  5 14:55:55 2010
@@ -0,0 +1,134 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<title>OpenCMIS Browser Binding Demo</title>
+<style type="text/css">
+  body {
+    font-family:Arial,sans-serif;
+    font-size:11pt;
+  }
+  .box {
+    border-width:1px;
+    border-style:solid;
+    width:100%;
+    padding:3px;
+  }
+  td {
+    padding:5px;
+  }
+</style>
+<script type="text/javascript">
+var repositoryUrl;
+
+function printRepositoryInfos(infos) {
+	for(repId in infos) {
+        var ri = infos[repId];		
+        document.getElementById('repositoryInfo').innerHTML = 
+            '<h2>Repsository "' + ri.repositoryName + '" (' + ri.repositoryId + ')</h2>' +
+            '<table>' +
+            '<tr><td>Id:</td><td>' + ri.repositoryId + '</td></tr>' +
+            '<tr><td>Name:</td><td>' + ri.repositoryName + '</td></tr>' +
+            '<tr><td>Description:</td><td>' + ri.repositoryDescription + '</td></tr>' +
+            '<tr><td>Product:</td><td>' + ri.vendorName + ' ' + ri.productName + ' ' + ri.productVersion + '</td></tr>' +
+            '<tr><td>Root folder id:</td><td>' + ri.rootFolderId + '</td></tr>' +
+            '<tr><td>Root folder id:</td><td>' + ri.rootFolderUrl + '</td></tr>' +
+            '</table>';
+            
+        repositoryUrl = ri.rootFolderUrl; // the InMemory repository has only one repository
+	}
+
+    var rootFolder = "/";
+	
+    var script1 = document.createElement("script");        
+    script1.setAttribute("src", repositoryUrl + rootFolder + "?method=getObject&callback=printObject");
+    script1.setAttribute("type","text/javascript");                
+    document.body.appendChild(script1);
+
+    var script2 = document.createElement("script");        
+    script2.setAttribute("src", repositoryUrl + rootFolder + "?method=getChildren&callback=printChildren");
+    script2.setAttribute("type","text/javascript");                
+    document.body.appendChild(script2);
+}
+
+function printObject(obj) {
+    var id = obj.properties["cmis:objectId"];
+    var name = obj.properties["cmis:name"];
+
+    var s = '<h2>Object "' + name + '" (' + id + ')</h2>';
+
+    s = s + '<h3>Properties</h3>';
+    s = s + '<table>';
+	
+    for(propertyId in obj.properties) {
+        var propertyValue = obj.properties[propertyId];
+        s = s + '<tr><td>' + propertyId + '</td><td>' + propertyValue + '</td></tr>';
+    }
+
+    s = s + '</table>';
+    
+    document.getElementById('objectInfo').innerHTML = s;
+}
+
+function printChildren(children) {
+    var s = '<h2>Children</h2>';
+
+    s = s + '<h3>Properties</h3>';
+
+    s = s + '<table><tr><th>Name</th><th>Type</th><th>MIME Type</th><th>Size</th>' +
+    '<th>Created By</th><th>Created At</th><th>Id</th></tr>';
+
+    for(var id in children.objects) {
+        var object = children.objects[id];
+
+        var name = object.properties["cmis:name"];
+        var type = object.properties["cmis:objectTypeId"];
+        var mimetype = "";
+        var size = "";
+        var createdBy = object.properties["cmis:createdBy"];
+        var creationDate = new Date(object.properties["cmis:creationDate"]);
+        var id = object.properties["cmis:objectId"];
+        var link = "";
+
+        if(object.properties["cmis:baseTypeId"] == "cmis:document") {
+            size = object.properties["cmis:contentStreamLength"];
+            mimetype = object.properties["cmis:contentStreamMimeType"];
+            link = encodeURI(repositoryUrl + '?objectId=' + id + '&method=getContentStream');
+        }
+
+        s = s + '<tr><td>';
+        if(link != "") {
+            s = s + '<a href="' + link + '">' + name + '</a>';
+        }
+        else {
+            s = s + name;
+        }
+        s = s + '</td><td>' + type + '</td><td>' + mimetype + '</td><td style="rext-align:right">' + size +
+         '</td><td>' + createdBy + '</td><td>' + creationDate + '</td><td>' + id + '</td></tr>';
+    }
+    
+    s = s + '</table>';
+    
+    document.getElementById('folderInfo').innerHTML = s;
+}
+</script>
+
+
+</head>
+<body>
+<h1>OpenCMIS Browser Binding - Demo</h1>
+<br/>
+<div id="repositoryInfo" class="box">
+repositoryInfo
+</div>
+<br/>
+<div id="objectInfo" class="box">
+objectInfo
+</div>
+<br/>
+<div id="folderInfo" class="box">
+folderInfo
+</div>
+
+<script type="text/javascript" src="browser?callback=printRepositoryInfos"></script>
+</body>
+</html>
\ No newline at end of file

Propchange: incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.html
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.html?rev=1004660&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.html (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.html Tue Oct  5 14:55:55 2010
@@ -0,0 +1,63 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<title>OpenCMIS Browser Binding</title>
+<style type="text/css">
+  body {
+    font-family:Arial,sans-serif;
+    font-size:11pt;
+  }
+</style>
+</head>
+<body>
+
+<h1>OpenCMIS Browser Binding</h1>
+
+<h2>Browser Binding</h2>
+
+<ul>
+<li><a href="demo.html">Demo Page</a></li>
+<li><a href="browser">Repository Infos</a></li>
+</ul>
+
+<table>
+<tr>
+<th></th>
+<th>access by object id</th>
+<th>access by path</th>
+</tr>
+<tr>
+<td>Object Data (object id 100 [root folder])</td>
+<td><a href="browser/A1?objectId=100&method=getObject">browser/A1?objectId=100&method=getObject</a></td>
+<td><a href="browser/A1/?&method=getObject">browser/A1/?method=getObject</a></td>
+</tr>
+<tr>
+<td>Object Data (object id 133 [document in root folder])</td>
+<td><a href="browser/A1?objectId=133&method=getObject">browser/A1?objectId=133&method=getObject</a></td>
+<td><a href="browser/A1/My_Document-0-1?method=getObject">browser/A1/My_Document-0-1?method=getObject</a></td>
+</tr>
+<tr>
+<td>Content (object id 133 [document in root folder])</td>
+<td><a href="browser/A1?objectId=133">browser/A1?objectId=133</a></td>
+<td><a href="browser/A1/My_Document-0-1">browser/A1/My_Document-0-1</a></td>
+</tr>
+<tr>
+<td>Folder children (object id 100 [root folder])</td>
+<td><a href="browser/A1?objectId=100">browser/A1?objectId=100</a></td>
+<td><a href="browser/A1/">browser/A1/</a></td>
+</tr>
+<tr>
+<td>Folder children (object id 101 [folder in root folder])</td>
+<td><a href="browser/A1?objectId=101">browser/A1?objectId=101</a></td>
+<td><a href="browser/A1/My_Folder-0-0">browser/A1/My_Folder-0-0</a></td>
+</tr>
+</table>
+
+<h2>AtomPub binding</h2>
+<a href="atom">AtomPub Service Document</a>
+
+<h2>WebServices binding</h2>
+<a href="services/RepositoryService">Web Services Overview</a>
+
+</body>
+</html>
\ No newline at end of file

Propchange: incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.html
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message