chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1043482 - in /incubator/chemistry/opencmis-browser-binding/trunk/src/main: java/org/apache/chemistry/opencmis/server/impl/browser/ java/org/apache/chemistry/opencmis/server/impl/browser/json/ webapp/
Date Wed, 08 Dec 2010 16:14:24 GMT
Author: fmui
Date: Wed Dec  8 16:14:23 2010
New Revision: 1043482

URL: http://svn.apache.org/viewvc?rev=1043482&view=rev
Log:
updated to the latest URL patterns proposal

Added:
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/UploadHttpServletRequestWrapper.java
  (with props)
Modified:
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java
    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/demo.html
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.html

Modified: 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=1043482&r1=1043481&r2=1043482&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java
(original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java
Wed Dec  8 16:14:23 2010
@@ -32,7 +32,6 @@ import org.apache.chemistry.opencmis.com
 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;
@@ -44,17 +43,26 @@ 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 ROOT_PATH_FRAGMENT = "root";
 
-    public static final String PARAM_METHOD = "method";
+    public static final String SELECTOR_CONTENT = "content";
+    public static final String SELECTOR_OBJECT = "object";
+    public static final String SELECTOR_CHILDREN = "children";
+
+    public static final String PARAM_SELECTOR = "selector";
     public static final String PARAM_CLIENTTOKEN = "clientToken";
     public static final String PARAM_INCLUDE_TYPE = "includeTypeInformation";
 
+    public static final String FIELD_ACTION = "action";
+    public static final String FIELD_OBJECT_ID = "objectId";
+
     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";
 
+    public enum CallUrl {
+        SERVICE, REPOSITORY, ROOT
+    }
+
     /**
      * Compiles the base URL for links, collections and templates.
      */
@@ -76,15 +84,15 @@ public class BrowserBindingUtils {
      */
     public static String getPath(HttpServletRequest request) {
         String[] pathFragments = HttpUtils.splitPath(request);
-        if (pathFragments.length < 1) {
+        if (pathFragments.length < 2) {
             return null;
         }
-        if (pathFragments.length == 1) {
+        if (pathFragments.length == 2) {
             return "/";
         }
 
         StringBuilder sb = new StringBuilder();
-        for (int i = 1; i < pathFragments.length; i++) {
+        for (int i = 2; i < pathFragments.length; i++) {
             if (pathFragments[i].length() == 0) {
                 continue;
             }
@@ -99,11 +107,14 @@ public class BrowserBindingUtils {
     /**
      * Returns the object id of the current request.
      */
-    public static void prepareContext(CallContext context, CmisService service, String repositoryId,
-            HttpServletRequest request) {
+    public static void prepareContext(CallContext context, CallUrl callUrl, CmisService service,
String repositoryId,
+            String objectId, HttpServletRequest request) {
+        if (callUrl != CallUrl.ROOT) {
+            return;
+        }
+
         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);

Modified: 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=1043482&r1=1043481&r2=1043482&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
(original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
Wed Dec  8 16:14:23 2010
@@ -18,6 +18,8 @@
  */
 package org.apache.chemistry.opencmis.server.impl.browser;
 
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
+
 import java.io.IOException;
 
 import javax.servlet.ServletConfig;
@@ -41,10 +43,12 @@ import org.apache.chemistry.opencmis.com
 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.impl.Constants;
 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.BrowserBindingUtils.CallUrl;
 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;
@@ -61,7 +65,8 @@ public class CmisBrowserBindingServlet e
 
     private static final Log LOG = LogFactory.getLog(CmisBrowserBindingServlet.class.getName());
 
-    private Dispatcher dispatcher;
+    private Dispatcher repositoryDispatcher;
+    private Dispatcher rootDispatcher;
     private CallContextHandler callContextHandler;
 
     @Override
@@ -79,15 +84,18 @@ public class CmisBrowserBindingServlet e
             }
         }
 
-        // initialize the dispatcher
-        dispatcher = new Dispatcher();
+        // initialize the dispatchers
+        repositoryDispatcher = new Dispatcher();
+        rootDispatcher = new Dispatcher();
 
         try {
-            dispatcher.addResource(BrowserBindingUtils.METHOD_GET_OBJECT, Dispatcher.METHOD_GET,
ObjectService.class,
+            repositoryDispatcher.addResource("", Dispatcher.METHOD_GET, RepositoryService.class,
"getRepositoryInfo");
+
+            rootDispatcher.addResource(BrowserBindingUtils.SELECTOR_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,
+            rootDispatcher.addResource(BrowserBindingUtils.SELECTOR_CONTENT, Dispatcher.METHOD_GET,
+                    ObjectService.class, "getContentStream");
+            rootDispatcher.addResource(BrowserBindingUtils.SELECTOR_CHILDREN, Dispatcher.METHOD_GET,
                     NavigationService.class, "getChildren");
         } catch (NoSuchMethodException e) {
             LOG.error("Cannot initialize dispatcher!", e);
@@ -154,38 +162,85 @@ public class CmisBrowserBindingServlet e
                 return;
             }
 
+            // select dispatcher
+
+            CallUrl callUrl = null;
+            if (pathFragments.length == 1) {
+                callUrl = CallUrl.REPOSITORY;
+            } else if (BrowserBindingUtils.ROOT_PATH_FRAGMENT.equals(pathFragments[1])) {
+                callUrl = CallUrl.ROOT;
+            }
+
+            if (callUrl == null) {
+                throw new CmisNotSupportedException("Unknown operation");
+            }
+
             String method = request.getMethod();
             String repositoryId = pathFragments[0];
+            boolean methodFound = false;
 
-            String resource = HttpUtils.getStringParameter(request, BrowserBindingUtils.PARAM_METHOD);
-
-            // add object id and object base type id to context
-            BrowserBindingUtils.prepareContext(context, service, repositoryId, request);
+            if (Dispatcher.METHOD_GET.equals(method)) {
+                String selector = HttpUtils.getStringParameter(request, BrowserBindingUtils.PARAM_SELECTOR);
+                String objectId = getStringParameter(request, Constants.PARAM_OBJECT_ID);
+
+                // add object id and object base type id to context
+                BrowserBindingUtils.prepareContext(context, callUrl, service, repositoryId,
objectId, request);
+
+                // dispatch
+                if (callUrl == CallUrl.REPOSITORY) {
+                    if (selector == null) {
+                        selector = "";
+                    }
 
-            // set default method if necessary
-            if (resource == null) {
-                try {
-                    BaseTypeId basetype = BaseTypeId.fromValue((String) 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;
+                    methodFound = repositoryDispatcher.dispatch(selector, method, context,
service, repositoryId,
+                            request, response);
+                } else if (callUrl == CallUrl.ROOT) {
+                    // set default method if necessary
+                    if (selector == null) {
+                        try {
+                            BaseTypeId basetype = BaseTypeId.fromValue((String) context
+                                    .get(BrowserBindingUtils.CONTEXT_BASETYPE_ID));
+                            switch (basetype) {
+                            case CMIS_DOCUMENT:
+                                selector = BrowserBindingUtils.SELECTOR_CONTENT;
+                                break;
+                            case CMIS_FOLDER:
+                                selector = BrowserBindingUtils.SELECTOR_CHILDREN;
+                                break;
+                            default:
+                                selector = BrowserBindingUtils.SELECTOR_OBJECT;
+                                break;
+                            }
+                        } catch (Exception e) {
+                            selector = BrowserBindingUtils.SELECTOR_OBJECT;
+                        }
                     }
-                } catch (Exception e) {
-                    resource = BrowserBindingUtils.METHOD_GET_OBJECT;
+
+                    methodFound = rootDispatcher.dispatch(selector, method, context, service,
repositoryId, request,
+                            response);
                 }
-            }
+            } else if (Dispatcher.METHOD_POST.equals(method)) {
+                UploadHttpServletRequestWrapper uploadRequest = new UploadHttpServletRequestWrapper(request);
 
-            // dispatch
-            boolean methodFound = dispatcher.dispatch(resource, method, context, service,
repositoryId, request,
-                    response);
+                String action = HttpUtils.getStringParameter(uploadRequest, BrowserBindingUtils.FIELD_ACTION);
+                String objectId = HttpUtils.getStringParameter(uploadRequest, BrowserBindingUtils.FIELD_OBJECT_ID);
+
+                if ((action == null) || (action.length() == 0)) {
+                    throw new CmisNotSupportedException("Unknown action");
+                }
+
+                // add object id and object base type id to context
+                BrowserBindingUtils.prepareContext(context, callUrl, service, repositoryId,
objectId, uploadRequest);
+
+                // dispatch
+                if (callUrl == CallUrl.REPOSITORY) {
+                    methodFound = repositoryDispatcher.dispatch(action, method, context,
service, repositoryId,
+                            request, response);
+                } else if (callUrl == CallUrl.ROOT) {
+                    methodFound = rootDispatcher.dispatch(action, method, context, service,
repositoryId, request,
+                            response);
+                }
+            }
 
             // if the dispatcher couldn't find a matching method, return an
             // error message

Modified: 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=1043482&r1=1043481&r2=1043482&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java
(original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java
Wed Dec  8 16:14:23 2010
@@ -18,20 +18,15 @@
  */
 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;
 
@@ -40,19 +35,8 @@ 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);
-            }
-        }
+        List<RepositoryInfo> infoDataList = service.getRepositoryInfos(null);
 
         UrlBuilder baseUrl = BrowserBindingUtils.compileBaseUrl(request, null);
 
@@ -63,4 +47,14 @@ public final class RepositoryService {
 
         BrowserBindingUtils.writeJSON(result, request, response);
     }
+
+    public static void getRepositoryInfo(CallContext context, CmisService service, String
repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        // execute
+        RepositoryInfo ri = service.getRepositoryInfo(repositoryId, null);
+
+        UrlBuilder baseUrl = BrowserBindingUtils.compileBaseUrl(request, null);
+
+        BrowserBindingUtils.writeJSON(JSONConverter.convert(ri, baseUrl), request, response);
+    }
 }

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/UploadHttpServletRequestWrapper.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/UploadHttpServletRequestWrapper.java?rev=1043482&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/UploadHttpServletRequestWrapper.java
(added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/UploadHttpServletRequestWrapper.java
Wed Dec  8 16:14:23 2010
@@ -0,0 +1,125 @@
+/*
+ * 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.InputStream;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
+
+public class UploadHttpServletRequestWrapper extends HttpServletRequestWrapper {
+    private boolean isMultipart;
+    private Map<String, String[]> parameters;
+    private InputStream stream;
+
+    public UploadHttpServletRequestWrapper(HttpServletRequest request) throws Exception {
+        this(request, 4 * 1024 * 1024);
+    }
+
+    public UploadHttpServletRequestWrapper(HttpServletRequest request, int memoryThreshold)
throws Exception {
+        super(request);
+
+        isMultipart = ServletFileUpload.isMultipartContent(request);
+
+        if (isMultipart) {
+            parameters = new HashMap<String, String[]>();
+
+            DiskFileItemFactory itemFactory = new DiskFileItemFactory();
+            itemFactory.setSizeThreshold(memoryThreshold);
+
+            ServletFileUpload upload = new ServletFileUpload(itemFactory);
+            @SuppressWarnings("unchecked")
+            List<FileItem> fileItems = upload.parseRequest(request);
+
+            for (FileItem item : fileItems) {
+                if (item.isFormField()) {
+                    String[] values = parameters.get(item.getFieldName());
+
+                    if (values == null) {
+                        parameters.put(item.getFieldName(), new String[] { item.getString()
});
+                    } else {
+                        String[] newValues = new String[values.length + 1];
+                        System.arraycopy(values, 0, newValues, 0, values.length);
+                        newValues[newValues.length - 1] = item.getString();
+                        parameters.put(item.getFieldName(), newValues);
+                    }
+                } else {
+                    stream = item.getInputStream();
+                    break;
+                }
+            }
+        }
+    }
+
+    @Override
+    public String getParameter(String name) {
+        if (!isMultipart) {
+            return super.getParameter(name);
+        }
+
+        String[] values = parameters.get(name);
+        if ((values == null) || (values.length == 0)) {
+            return null;
+        }
+
+        return values[0];
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Map<String, String[]> getParameterMap() {
+        if (!isMultipart) {
+            return super.getParameterMap();
+        }
+
+        return parameters;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Enumeration<String> getParameterNames() {
+        if (!isMultipart) {
+            return super.getParameterNames();
+        }
+
+        return Collections.enumeration(parameters.keySet());
+    }
+
+    @Override
+    public String[] getParameterValues(String name) {
+        if (!isMultipart) {
+            return super.getParameterValues(name);
+        }
+
+        return parameters.get(name);
+    }
+
+    public InputStream getStream() {
+        return stream;
+    }
+}

Propchange: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/UploadHttpServletRequestWrapper.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=1043482&r1=1043481&r2=1043482&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
Wed Dec  8 16:14:23 2010
@@ -31,6 +31,7 @@ public class JSONConstants {
     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_REPOSITORY_URL = "repositoryUrl";
     public final static String REPINFO_ROOT_FOLDER_URL = "rootFolderUrl";
     public final static String REPINFO_CAPABILITIES = "capabilities";
     public final static String REPINFO_ACL_CAPABILITIES = "aclCapabilities";

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=1043482&r1=1043481&r2=1043482&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
Wed Dec  8 16:14:23 2010
@@ -47,6 +47,7 @@ import org.apache.chemistry.opencmis.com
 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.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils;
 import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 
@@ -67,9 +68,6 @@ public class JSONConverter extends JSONC
             return null;
         }
 
-        UrlBuilder repUrl = new UrlBuilder(baseUrl);
-        repUrl.addPathSegment(repositoryInfo.getId());
-
         JSONObject result = new JSONObject();
 
         result.put(REPINFO_ID, repositoryInfo.getId());
@@ -79,7 +77,6 @@ public class JSONConverter extends JSONC
         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());
@@ -100,6 +97,14 @@ public class JSONConverter extends JSONC
         result.put(REPINFO_PRINCIPAL_ID_ANONYMOUS, repositoryInfo.getPrincipalIdAnonymous());
         result.put(REPINFO_PRINCIPAL_ID_ANYONE, repositoryInfo.getPrincipalIdAnyone());
 
+        UrlBuilder repositoryUrl = new UrlBuilder(baseUrl);
+        repositoryUrl.addPathSegment(repositoryInfo.getId());
+        result.put(REPINFO_REPOSITORY_URL, repositoryUrl.toString());
+
+        UrlBuilder rootUrl = new UrlBuilder(repositoryUrl);
+        rootUrl.addPathSegment(BrowserBindingUtils.ROOT_PATH_FRAGMENT);
+        result.put(REPINFO_ROOT_FOLDER_URL, rootUrl.toString());
+
         return result;
     }
 

Modified: 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=1043482&r1=1043481&r2=1043482&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.html (original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/demo.html Wed Dec 
8 16:14:23 2010
@@ -18,7 +18,7 @@
   }
 </style>
 <script type="text/javascript">
-var repositoryUrl;
+var rootFolderUrl;
 
 function printRepositoryInfos(infos) {
 	for(repId in infos) {
@@ -31,21 +31,22 @@ function printRepositoryInfos(infos) {
             '<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>Repository URL:</td><td>' + ri.repositoryUrl
+ '</td></tr>' +
             '<tr><td>Root folder URL:</td><td>' + ri.rootFolderUrl
+ '</td></tr>' +
             '</table>';
             
-        repositoryUrl = ri.rootFolderUrl; // the InMemory repository has only one repository
+        rootFolderUrl = ri.rootFolderUrl; // the InMemory repository has only one repository
 	}
 
     var rootFolder = "/";
 	
     var script1 = document.createElement("script");        
-    script1.setAttribute("src", repositoryUrl + rootFolder + "?method=getObject&clientToken=printObject");
+    script1.setAttribute("src", rootFolderUrl + rootFolder + "?selector=object&clientToken=printObject");
     script1.setAttribute("type","text/javascript");                
     document.body.appendChild(script1);
 
     var script2 = document.createElement("script");        
-    script2.setAttribute("src", repositoryUrl + rootFolder + "?method=getChildren&clientToken=printChildren");
+    script2.setAttribute("src", rootFolderUrl + rootFolder + "?selector=children&clientToken=printChildren");
     script2.setAttribute("type","text/javascript");                
     document.body.appendChild(script2);
 }
@@ -92,7 +93,7 @@ function printChildren(children) {
         if(object.properties["cmis:baseTypeId"] == "cmis:document") {
             size = object.properties["cmis:contentStreamLength"];
             mimetype = object.properties["cmis:contentStreamMimeType"];
-            link = encodeURI(repositoryUrl + '?objectId=' + id + '&method=getContentStream');
+            link = encodeURI(rootFolderUrl + '?objectId=' + id + '&selector=content');
         }
 
         s = s + '<tr><td>';

Modified: 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=1043482&r1=1043481&r2=1043482&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.html (original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/index.html Wed Dec
 8 16:14:23 2010
@@ -28,28 +28,28 @@
 </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>
+<td><a href="browser/A1/root?objectId=100&selector=object">browser/A1/root?objectId=100&selector=object</a></td>
+<td><a href="browser/A1/root/?&selector=object">browser/A1/root/?selector=object</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>
+<td><a href="browser/A1/root?objectId=133&selector=object">browser/A1/root?objectId=133&selector=object</a></td>
+<td><a href="browser/A1/root/My_Document-0-1?selector=object">browser/A1/root/My_Document-0-1?selector=object</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>
+<td><a href="browser/A1/root?objectId=133">browser/A1/root?objectId=133</a></td>
+<td><a href="browser/A1/root/My_Document-0-1">browser/A1/root/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>
+<td><a href="browser/A1/root?objectId=100">browser/A1/root?objectId=100</a></td>
+<td><a href="browser/A1/root/">browser/A1/root/</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>
+<td><a href="browser/A1/root?objectId=101">browser/A1/root?objectId=101</a></td>
+<td><a href="browser/A1/root/My_Folder-0-0">browser/A1/root/My_Folder-0-0</a></td>
 </tr>
 </table>
 



Mime
View raw message