chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1094397 [2/3] - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings: ./ src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ src/main/java/org/apache/chemistry/opencmis/server/impl/browser/...
Date Mon, 18 Apr 2011 09:29:46 GMT
Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java?rev=1094397&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java Mon Apr 18 09:29:45 2011
@@ -0,0 +1,181 @@
+/*
+ * 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.getStringParameter;
+
+import java.math.BigInteger;
+import java.util.List;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
+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.JSONArray;
+import org.json.simple.JSONObject;
+import org.json.simple.JSONValue;
+
+/**
+ * Repository Service operations.
+ */
+public final class RepositoryService {
+
+    /**
+     * getRepositories.
+     */
+    @SuppressWarnings("unchecked")
+    public static void getRepositories(CallContext context, CmisService service, HttpServletRequest request,
+            HttpServletResponse response) throws Exception {
+        // execute
+        List<RepositoryInfo> infoDataList = service.getRepositoryInfos(null);
+
+        JSONObject result = new JSONObject();
+        for (RepositoryInfo ri : infoDataList) {
+            result.put(ri.getId(), JSONConverter.convert(ri, request));
+        }
+
+        response.setStatus(HttpServletResponse.SC_OK);
+        BrowserBindingUtils.writeJSON(result, request, response);
+    }
+
+    /**
+     * getRepositoryInfo.
+     */
+    public static void getRepositoryInfo(CallContext context, CmisService service, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        // execute
+        RepositoryInfo ri = service.getRepositoryInfo(repositoryId, null);
+        JSONObject jsonRi = JSONConverter.convert(ri, request);
+
+        response.setStatus(HttpServletResponse.SC_OK);
+        BrowserBindingUtils.writeJSON(jsonRi, request, response);
+    }
+
+    /**
+     * getLastResult.
+     */
+    @SuppressWarnings("unchecked")
+    public static void getLastResult(CallContext context, CmisService service, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+
+        String transaction = getStringParameter(request, BrowserBindingUtils.PARAM_TRANSACTION);
+        String cookieName = BrowserBindingUtils.getCookieName(transaction);
+        String cookieValue = null;
+
+        if (request.getCookies() != null) {
+            for (Cookie cookie : request.getCookies()) {
+                if (cookieName.equals(cookie.getName())) {
+                    cookieValue = cookie.getValue();
+                    break;
+                }
+            }
+        }
+
+        JSONObject result = null;
+        try {
+            if (cookieValue == null) {
+                cookieValue = BrowserBindingUtils.createCookieValue(0, null, "invalidArgument", "Unknown transaction!");
+            }
+
+            result = (JSONObject) JSONValue.parse(cookieValue);
+        } catch (Exception pe) {
+            result.put("code", 0);
+            result.put("objectId", null);
+            result.put("message", "Cookie pasring error!");
+        }
+
+        response.setStatus(HttpServletResponse.SC_OK);
+        BrowserBindingUtils.writeJSON((JSONObject) JSONValue.parse(cookieValue), request, response);
+    }
+
+    /**
+     * getTypeChildren.
+     */
+    public static void getTypeChildren(CallContext context, CmisService service, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        // get parameters
+        String typeId = getStringParameter(request, Constants.PARAM_TYPE_ID);
+        boolean includePropertyDefinitions = getBooleanParameter(request, Constants.PARAM_PROPERTY_DEFINITIONS, false);
+        BigInteger maxItems = getBigIntegerParameter(request, Constants.PARAM_MAX_ITEMS);
+        BigInteger skipCount = getBigIntegerParameter(request, Constants.PARAM_SKIP_COUNT);
+
+        // execute
+        TypeDefinitionList typeList = service.getTypeChildren(repositoryId, typeId, includePropertyDefinitions,
+                maxItems, skipCount, null);
+        JSONObject jsonTypeList = JSONConverter.convert(typeList);
+
+        response.setStatus(HttpServletResponse.SC_OK);
+        BrowserBindingUtils.writeJSON(jsonTypeList, request, response);
+    }
+
+    /**
+     * getTypeDescendants.
+     */
+    @SuppressWarnings("unchecked")
+    public static void getTypeDescendants(CallContext context, CmisService service, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        // get parameters
+        String typeId = getStringParameter(request, Constants.PARAM_TYPE_ID);
+        BigInteger depth = getBigIntegerParameter(request, Constants.PARAM_DEPTH);
+        boolean includePropertyDefinitions = getBooleanParameter(request, Constants.PARAM_PROPERTY_DEFINITIONS, false);
+
+        // execute
+        List<TypeDefinitionContainer> typeTree = service.getTypeDescendants(repositoryId, typeId, depth,
+                includePropertyDefinitions, null);
+
+        if (typeTree == null) {
+            throw new CmisRuntimeException("Type tree is null!");
+        }
+
+        JSONArray jsonTypeTree = new JSONArray();
+        for (TypeDefinitionContainer container : typeTree) {
+            jsonTypeTree.add(JSONConverter.convert(container));
+        }
+
+        response.setStatus(HttpServletResponse.SC_OK);
+        BrowserBindingUtils.writeJSON(jsonTypeTree, request, response);
+    }
+
+    /**
+     * getTypeDefintion.
+     */
+    public static void getTypeDefintion(CallContext context, CmisService service, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        // get parameters
+        String typeId = getStringParameter(request, Constants.PARAM_TYPE_ID);
+
+        // execute
+        TypeDefinition type = service.getTypeDefinition(repositoryId, typeId, null);
+        JSONObject jsonType = JSONConverter.convert(type);
+
+        response.setStatus(HttpServletResponse.SC_OK);
+        BrowserBindingUtils.writeJSON(jsonType, request, response);
+    }
+}

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

Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/TypeCache.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/TypeCache.java?rev=1094397&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/TypeCache.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/TypeCache.java Mon Apr 18 09:29:45 2011
@@ -0,0 +1,63 @@
+/*
+ * 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.util.HashMap;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.server.CmisService;
+import org.apache.chemistry.opencmis.commons.server.ObjectInfo;
+
+/**
+ * Temporary type cache used for one call.
+ */
+public class TypeCache {
+
+    private String repositoryId;
+    private CmisService service;
+    private Map<String, TypeDefinition> typeDefinitions;
+
+    public TypeCache(String repositoryId, CmisService service) {
+        this.repositoryId = repositoryId;
+        this.service = service;
+        typeDefinitions = new HashMap<String, TypeDefinition>();
+    }
+
+    public TypeDefinition getTypeDefinition(String typeId) {
+        TypeDefinition type = typeDefinitions.get(typeId);
+        if (type == null) {
+            type = service.getTypeDefinition(repositoryId, typeId, null);
+            if (type != null) {
+                typeDefinitions.put(type.getId(), type);
+            }
+        }
+
+        return type;
+    }
+
+    public TypeDefinition getTypeDefinitionForObject(String objectId) {
+        ObjectInfo info = service.getObjectInfo(repositoryId, objectId);
+        if (info == null) {
+            return null;
+        }
+
+        return getTypeDefinition(info.getTypeId());
+    }
+}

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

Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/VersioningService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/VersioningService.java?rev=1094397&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/VersioningService.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/VersioningService.java Mon Apr 18 09:29:45 2011
@@ -0,0 +1,70 @@
+/*
+ * 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.getStringParameter;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.chemistry.opencmis.commons.data.ObjectData;
+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.JSONArray;
+
+/**
+ * Versioning Service operations.
+ */
+public class VersioningService {
+
+    /**
+     * getAllVersions.
+     */
+    @SuppressWarnings("unchecked")
+    public static void getAllVersions(CallContext context, CmisService service, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        // get parameters
+        String objectId = (String) context.get(BrowserBindingUtils.CONTEXT_OBJECT_ID);
+        String filter = getStringParameter(request, Constants.PARAM_FILTER);
+        Boolean includeAllowableActions = getBooleanParameter(request, Constants.PARAM_ALLOWABLE_ACTIONS);
+
+        // execute
+        List<ObjectData> versions = service.getAllVersions(repositoryId, objectId, null, filter,
+                includeAllowableActions, null);
+
+        if (versions == null) {
+            throw new CmisRuntimeException("Versions are null!");
+        }
+
+        TypeCache typeCache = new TypeCache(repositoryId, service);
+        JSONArray jsonVersions = new JSONArray();
+        for (ObjectData version : versions) {
+            jsonVersions.add(JSONConverter.convert(version, typeCache));
+        }
+
+        response.setStatus(HttpServletResponse.SC_OK);
+        BrowserBindingUtils.writeJSON(jsonVersions, request, response);
+    }
+}

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

Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConstants.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConstants.java?rev=1094397&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConstants.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConstants.java Mon Apr 18 09:29:45 2011
@@ -0,0 +1,183 @@
+/*
+ * 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.json;
+
+/**
+ * JSON object constants.
+ */
+public class JSONConstants {
+
+    public final static String ERROR_EXCEPTION = "exception";
+    public final static String ERROR_MESSAGE = "message";
+    public final static String ERROR_STACKTRACE = "stacktrace";
+
+    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_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";
+    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 = "capabilityContentStreamUpdatability";
+    public final static String JSON_CAP_CHANGES = "capabilityChanges";
+    public final static String JSON_CAP_RENDITIONS = "capabilityRenditions";
+    public final static String JSON_CAP_GET_DESCENDANTS = "capabilityGetDescendants";
+    public final static String JSON_CAP_GET_FOLDER_TREE = "capabilityGetFolderTree";
+    public final static String JSON_CAP_MULTIFILING = "capabilityMultifiling";
+    public final static String JSON_CAP_UNFILING = "capabilityUnfiling";
+    public final static String JSON_CAP_VERSION_SPECIFIC_FILING = "capabilityVersionSpecificFiling";
+    public final static String JSON_CAP_PWC_SEARCHABLE = "capabilityPWCSearchable";
+    public final static String JSON_CAP_PWC_UPDATABLE = "capabilityPWCUpdatable";
+    public final static String JSON_CAP_ALL_VERSIONS_SEARCHABLE = "capabilityAllVersionsSearchable";
+    public final static String JSON_CAP_QUERY = "capabilityQuery";
+    public final static String JSON_CAP_JOIN = "capabilityJoin";
+    public final static String JSON_CAP_ACL = "capabilityACL";
+
+    public final static String JSON_ACLCAP_SUPPORTED_PERMISSIONS = "supportedPermissions";
+    public final static String JSON_ACLCAP_ACL_PROPAGATION = "propagation";
+    public final static String JSON_ACLCAP_PERMISSIONS = "permissions";
+    public final static String JSON_ACLCAP_PERMISSION_MAPPING = "permissionMapping";
+
+    public final static String JSON_ACLCAP_PERMISSION_PERMISSION = "permission";
+    public final static String JSON_ACLCAP_PERMISSION_DESCRIPTION = "description";
+
+    public final static String JSON_ACLCAP_MAPPING_KEY = "key";
+    public final static String JSON_ACLCAP_MAPPING_PERMISSION = "permission";
+
+    public final static String JSON_OBJECT_PROPERTIES = "properties";
+    public final static String JSON_OBJECT_ALLOWABLE_ACTIONS = "allowableActions";
+    public final static String JSON_OBJECT_RELATIONSHIPS = "relationships";
+    public final static String JSON_OBJECT_CHANGE_EVENT_INFO = "changeEventInfo";
+    public final static String JSON_OBJECT_ACL = "acl";
+    public final static String JSON_OBJECT_EXACT_ACL = "exactACL";
+    public final static String JSON_OBJECT_POLICY_IDS = "policyIds";
+    public final static String JSON_OBJECT_RENDITIONS = "renditions";
+
+    public final static String JSON_OBJECTINFOLDER_OBJECT = "object";
+    public final static String JSON_OBJECTINFOLDER_PATH_SEGMENT = "pathSegment";
+    public final static String JSON_OBJECTPARENTS_OBJECT = "object";
+    public final static String JSON_OBJECTPARENTS_RELATIVE_PATH_SEGMENT = "relativePathSegment";
+
+    public final static String JSON_PROPERTY_ID = "id";
+    public final static String JSON_PROPERTY_LOCALNAME = "localName";
+    public final static String JSON_PROPERTY_DISPLAYNAME = "displayName";
+    public final static String JSON_PROPERTY_QUERYNAME = "queryName";
+    public final static String JSON_PROPERTY_VALUE = "value";
+    public final static String JSON_PROPERTY_DATATYPE = "type";
+    public final static String JSON_PROPERTY_CARDINALITY = "cardinality";
+
+    public final static String JSON_CHANGE_EVENT_TYPE = "changeType";
+    public final static String JSON_CHANGE_EVENT_TIME = "changeTime";
+
+    public final static String JSON_ACL_ACES = "aces";
+    public final static String JSON_ACL_IS_EXACT = "isExact";
+
+    public final static String JSON_ACE_PRINCIPAL = "princial";
+    public final static String JSON_ACE_PRINCIPAL_ID = "princialId";
+    public final static String JSON_ACE_PERMISSIONS = "permissions";
+    public final static String JSON_ACE_IS_DIRECT = "isDirect";
+
+    public final static String JSON_RENDITION_STREAM_ID = "streamId";
+    public final static String JSON_RENDITION_MIMETYPE = "mimeType";
+    public final static String JSON_RENDITION_LENGTH = "length";
+    public final static String JSON_RENDITION_KIND = "kind";
+    public final static String JSON_RENDITION_TITLE = "title";
+    public final static String JSON_RENDITION_HEIGHT = "height";
+    public final static String JSON_RENDITION_WIDTH = "width";
+    public final static String JSON_RENDITION_DOCUMENT_ID = "renditionDocumentId";
+
+    public final static String JSON_OBJECTLIST_OBJECTS = "objects";
+    public final static String JSON_OBJECTLIST_HAS_MORE_ITEMS = "hasMoreItems";
+    public final static String JSON_OBJECTLIST_NUM_ITEMS = "numItems";
+
+    public final static String JSON_OBJECTINFOLDERLIST_OBJECTS = "objects";
+    public final static String JSON_OBJECTINFOLDERLIST_HAS_MORE_ITEMS = "hasMoreItems";
+    public final static String JSON_OBJECTINFOLDERLIST_NUM_ITEMS = "numItems";
+
+    public final static String JSON_OBJECTINFOLDERCONTAINER_OBJECT = "object";
+    public final static String JSON_OBJECTINFOLDERCONTAINER_CHILDREN = "children";
+
+    public final static String JSON_TYPE_ID = "id";
+    public final static String JSON_TYPE_LOCALNAME = "localName";
+    public final static String JSON_TYPE_LOCALNAMESPACE = "localNamespace";
+    public final static String JSON_TYPE_DISPLAYNAME = "displayName";
+    public final static String JSON_TYPE_QUERYNAME = "queryName";
+    public final static String JSON_TYPE_DESCRIPTION = "description";
+    public final static String JSON_TYPE_BASE_ID = "baseId";
+    public final static String JSON_TYPE_PARENT_ID = "parentId";
+    public final static String JSON_TYPE_CREATABLE = "creatable";
+    public final static String JSON_TYPE_FILEABLE = "fileable";
+    public final static String JSON_TYPE_QUERYABLE = "queryable";
+    public final static String JSON_TYPE_FULLTEXT_INDEXED = "fulltextIndexed";
+    public final static String JSON_TYPE_INCLUDE_IN_SUPERTYPE_QUERY = "includedInSupertypeQuery";
+    public final static String JSON_TYPE_CONTROLABLE_POLICY = "controllablePolicy";
+    public final static String JSON_TYPE_CONTROLABLE_ACL = "controllableACL";
+    public final static String JSON_TYPE_PROPERTY_DEFINITIONS = "propertyDefinitions";
+
+    public final static String JSON_TYPE_VERSIONABLE = "versionable"; // document
+    public final static String JSON_TYPE_CONTENTSTREAM_ALLOWED = "contentStreamAllowed"; // document
+
+    public final static String JSON_TYPE_ALLOWED_SOURCE_TYPES = "allowedSourceTypes"; // relationship
+    public final static String JSON_TYPE_ALLOWED_TARGET_TYPES = "allowedTargetTypes"; // relationship
+
+    public final static String JSON_PROPERTYTYPE_ID = "id";
+    public final static String JSON_PROPERTYTYPE_LOCALNAME = "localName";
+    public final static String JSON_PROPERTYTYPE_LOCALNAMESPACE = "localNamespace";
+    public final static String JSON_PROPERTYTYPE_DISPLAYNAME = "displayName";
+    public final static String JSON_PROPERTYTYPE_QUERYNAME = "queryName";
+    public final static String JSON_PROPERTYTYPE_DESCRIPTION = "description";
+    public final static String JSON_PROPERTYTYPE_PROPERTY_TYPE = "propertyType";
+    public final static String JSON_PROPERTYTYPE_CARDINALITY = "cardinality";
+    public final static String JSON_PROPERTYTYPE_UPDATABILITY = "updatability";
+    public final static String JSON_PROPERTYTYPE_INHERITED = "inherited";
+    public final static String JSON_PROPERTYTYPE_REQUIRED = "required";
+    public final static String JSON_PROPERTYTYPE_QUERYABLE = "queryable";
+    public final static String JSON_PROPERTYTYPE_OPENCHOICE = "openChoice";
+
+    public final static String JSON_PROPERTYTYPE_DEAULT_VALUE = "defaultValue";
+
+    public final static String JSON_PROPERTYTYPE_MAX_LENGTH = "maxLength";
+    public final static String JSON_PROPERTYTYPE_MIN_VALUE = "minValue";
+    public final static String JSON_PROPERTYTYPE_MAX_VALUE = "maxValue";
+    public final static String JSON_PROPERTYTYPE_MAX_PRECISION = "precision";
+    public final static String JSON_PROPERTYTYPE_MAX_RESOLUTION = "resolution";
+
+    public final static String JSON_PROPERTYTYPE_CHOICE_DISPLAYNAME = "displayName";
+    public final static String JSON_PROPERTYTYPE_CHOICE_VALUE = "value";
+    public final static String JSON_PROPERTYTYPE_CHOICE_CHOICE = "choice";
+
+    public final static String JSON_TYPESLIST_TYPES = "types";
+    public final static String JSON_TYPESLIST_HAS_MORE_ITEMS = "hasMoreItems";
+    public final static String JSON_TYPESLIST_NUM_ITEMS = "numItems";
+
+    public final static String JSON_TYPESCONTAINER_TYPE = "type";
+    public final static String JSON_TYPESCONTAINER_CHILDREN = "children";
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java?rev=1094397&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java Mon Apr 18 09:29:45 2011
@@ -0,0 +1,733 @@
+/*
+ * 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.json;
+
+import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.chemistry.opencmis.commons.data.Ace;
+import org.apache.chemistry.opencmis.commons.data.Acl;
+import org.apache.chemistry.opencmis.commons.data.AclCapabilities;
+import org.apache.chemistry.opencmis.commons.data.AllowableActions;
+import org.apache.chemistry.opencmis.commons.data.ChangeEventInfo;
+import org.apache.chemistry.opencmis.commons.data.ObjectData;
+import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
+import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
+import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
+import org.apache.chemistry.opencmis.commons.data.ObjectList;
+import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
+import org.apache.chemistry.opencmis.commons.data.PermissionMapping;
+import org.apache.chemistry.opencmis.commons.data.PropertyBoolean;
+import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.data.PropertyDateTime;
+import org.apache.chemistry.opencmis.commons.data.PropertyDecimal;
+import org.apache.chemistry.opencmis.commons.data.PropertyHtml;
+import org.apache.chemistry.opencmis.commons.data.PropertyId;
+import org.apache.chemistry.opencmis.commons.data.PropertyInteger;
+import org.apache.chemistry.opencmis.commons.data.PropertyString;
+import org.apache.chemistry.opencmis.commons.data.PropertyUri;
+import org.apache.chemistry.opencmis.commons.data.RenditionData;
+import org.apache.chemistry.opencmis.commons.data.RepositoryCapabilities;
+import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PermissionDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.RelationshipTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
+import org.apache.chemistry.opencmis.commons.enums.Action;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.commons.enums.Cardinality;
+import org.apache.chemistry.opencmis.commons.enums.PropertyType;
+import org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils;
+import org.apache.chemistry.opencmis.server.impl.browser.TypeCache;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+
+/**
+ * OpenCMIS objects to JSON converter.
+ */
+public class JSONConverter extends JSONConstants {
+
+    /**
+     * Private constructor.
+     */
+    private JSONConverter() {
+    }
+
+    /**
+     * Converts a repository info object.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(RepositoryInfo repositoryInfo, HttpServletRequest request) {
+        if (repositoryInfo == null) {
+            return null;
+        }
+
+        JSONObject result = new JSONObject();
+
+        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_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();
+
+            for (BaseTypeId type : repositoryInfo.getChangesOnType()) {
+                changesOnType.add(getJSONStringValue(type));
+            }
+
+            result.put(REPINFO_CHANGES_ON_TYPE, changesOnType);
+        }
+
+        result.put(REPINFO_PRINCIPAL_ID_ANONYMOUS, repositoryInfo.getPrincipalIdAnonymous());
+        result.put(REPINFO_PRINCIPAL_ID_ANYONE, repositoryInfo.getPrincipalIdAnyone());
+
+        result.put(REPINFO_REPOSITORY_URL, BrowserBindingUtils.compileRepositoryUrl(request, repositoryInfo.getId())
+                .toString());
+        result.put(REPINFO_ROOT_FOLDER_URL, BrowserBindingUtils.compileRootUrl(request, repositoryInfo.getId())
+                .toString());
+
+        return result;
+    }
+
+    /**
+     * Converts a capabilities object.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(RepositoryCapabilities capabilities) {
+        if (capabilities == null) {
+            return null;
+        }
+
+        JSONObject result = new JSONObject();
+
+        result.put(JSON_CAP_CONTENT_STREAM_UPDATES, getJSONStringValue(capabilities.getContentStreamUpdatesCapability()
+                .value()));
+        result.put(JSON_CAP_CHANGES, getJSONStringValue(capabilities.getChangesCapability().value()));
+        result.put(JSON_CAP_RENDITIONS, getJSONStringValue(capabilities.getRenditionsCapability().value()));
+        result.put(JSON_CAP_GET_DESCENDANTS, capabilities.isGetDescendantsSupported());
+        result.put(JSON_CAP_GET_FOLDER_TREE, capabilities.isGetFolderTreeSupported());
+        result.put(JSON_CAP_MULTIFILING, capabilities.isMultifilingSupported());
+        result.put(JSON_CAP_UNFILING, capabilities.isUnfilingSupported());
+        result.put(JSON_CAP_VERSION_SPECIFIC_FILING, capabilities.isVersionSpecificFilingSupported());
+        result.put(JSON_CAP_PWC_SEARCHABLE, capabilities.isPwcSearchableSupported());
+        result.put(JSON_CAP_PWC_UPDATABLE, capabilities.isPwcUpdatableSupported());
+        result.put(JSON_CAP_ALL_VERSIONS_SEARCHABLE, capabilities.isAllVersionsSearchableSupported());
+        result.put(JSON_CAP_QUERY, getJSONStringValue(capabilities.getQueryCapability().value()));
+        result.put(JSON_CAP_JOIN, getJSONStringValue(capabilities.getJoinCapability().value()));
+        result.put(JSON_CAP_ACL, getJSONStringValue(capabilities.getAclCapability().value()));
+
+        return result;
+    }
+
+    /**
+     * Converts an ACL capabilities object.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(AclCapabilities capabilities) {
+        if (capabilities == null) {
+            return null;
+        }
+
+        JSONObject result = new JSONObject();
+
+        result.put(JSON_ACLCAP_SUPPORTED_PERMISSIONS,
+                getJSONStringValue(capabilities.getSupportedPermissions().value()));
+        result.put(JSON_ACLCAP_ACL_PROPAGATION, getJSONStringValue(capabilities.getAclPropagation().value()));
+
+        // permissions
+        if (capabilities.getPermissions() != null) {
+            JSONArray permissions = new JSONArray();
+
+            for (PermissionDefinition permDef : capabilities.getPermissions()) {
+                JSONObject permission = new JSONObject();
+                permission.put(JSON_ACLCAP_PERMISSION_PERMISSION, permDef.getId());
+                permission.put(JSON_ACLCAP_PERMISSION_DESCRIPTION, permDef.getDescription());
+
+                permissions.add(permission);
+            }
+
+            result.put(JSON_ACLCAP_PERMISSIONS, permissions);
+        }
+
+        // permission mapping
+
+        if (capabilities.getPermissionMapping() != null) {
+            JSONArray permissionMapping = new JSONArray();
+
+            for (PermissionMapping permMap : capabilities.getPermissionMapping().values()) {
+                JSONArray mappingPermissions = new JSONArray();
+                if (permMap.getPermissions() != null) {
+                    for (String p : permMap.getPermissions()) {
+                        mappingPermissions.add(p);
+                    }
+                }
+
+                JSONObject mapping = new JSONObject();
+                mapping.put(JSON_ACLCAP_MAPPING_KEY, permMap.getKey());
+                mapping.put(JSON_ACLCAP_MAPPING_PERMISSION, mappingPermissions);
+
+                permissionMapping.add(mapping);
+            }
+
+            result.put(JSON_ACLCAP_PERMISSION_MAPPING, permissionMapping);
+        }
+
+        return result;
+    }
+
+    /**
+     * Converts an object.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(ObjectData object, TypeCache typeCache) {
+        if (object == null) {
+            return null;
+        }
+
+        JSONObject result = new JSONObject();
+
+        // properties
+        if (object.getProperties() != null) {
+            JSONObject properties = new JSONObject();
+
+            for (PropertyData<?> property : object.getProperties().getPropertyList()) {
+                TypeDefinition type = null;
+                if (typeCache != null) {
+                    type = typeCache.getTypeDefinitionForObject(object.getId());
+                }
+
+                PropertyDefinition<?> propDef = null;
+                if (type != null) {
+                    propDef = type.getPropertyDefinitions().get(property.getId());
+                }
+
+                properties.put(property.getId(), convert(property, propDef));
+            }
+
+            result.put(JSON_OBJECT_PROPERTIES, properties);
+        }
+
+        // allowable actions
+        if (object.getAllowableActions() != null) {
+            result.put(JSON_OBJECT_ALLOWABLE_ACTIONS, convert(object.getAllowableActions()));
+        }
+
+        // relationships
+        if (object.getRelationships() != null) {
+            JSONArray relationships = new JSONArray();
+
+            for (ObjectData relationship : object.getRelationships()) {
+                relationships.add(convert(relationship, typeCache));
+            }
+
+            result.put(JSON_OBJECT_RELATIONSHIPS, relationships);
+        }
+
+        // change event info
+        if (object.getChangeEventInfo() != null) {
+            JSONObject changeEventInfo = new JSONObject();
+
+            ChangeEventInfo cei = object.getChangeEventInfo();
+            changeEventInfo.put(JSON_CHANGE_EVENT_TYPE, getJSONStringValue(cei.getChangeType().value()));
+            changeEventInfo.put(JSON_CHANGE_EVENT_TIME, getJSONValue(cei.getChangeTime()));
+
+            result.put(JSON_OBJECT_CHANGE_EVENT_INFO, changeEventInfo);
+        }
+
+        // ACL
+        if ((object.getAcl() != null) && (object.getAcl().getAces() != null)) {
+            result.put(JSON_OBJECT_ACL, convert(object.getAcl()));
+            result.put(JSON_OBJECT_EXACT_ACL, object.isExactAcl());
+        }
+
+        // policy ids
+        if ((object.getPolicyIds() != null) && (object.getPolicyIds().getPolicyIds() != null)) {
+            JSONArray policyIds = new JSONArray();
+
+            for (String pi : object.getPolicyIds().getPolicyIds()) {
+                policyIds.add(pi);
+            }
+
+            result.put(JSON_OBJECT_POLICY_IDS, policyIds);
+        }
+
+        // renditions
+        if (object.getRenditions() != null) {
+            JSONArray renditions = new JSONArray();
+
+            for (RenditionData rendition : object.getRenditions()) {
+                renditions.add(convert(rendition));
+            }
+
+            result.put(JSON_OBJECT_RENDITIONS, renditions);
+        }
+
+        return result;
+    }
+
+    /**
+     * Converts a property.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(PropertyData<?> property, PropertyDefinition<?> propDef) {
+        if (property == null) {
+            return null;
+        }
+
+        JSONObject result = new JSONObject();
+
+        result.put(JSON_PROPERTY_ID, property.getId());
+        result.put(JSON_PROPERTY_LOCALNAME, property.getLocalName());
+        result.put(JSON_PROPERTY_DISPLAYNAME, property.getDisplayName());
+        result.put(JSON_PROPERTY_QUERYNAME, property.getQueryName());
+
+        if (propDef != null) {
+            result.put(JSON_PROPERTY_DATATYPE, propDef.getPropertyType().value());
+            result.put(JSON_PROPERTY_CARDINALITY, propDef.getCardinality().value());
+
+            if ((property.getValues() == null) || (property.getValues().size() == 0)) {
+                result.put(JSON_PROPERTY_VALUE, null);
+            } else if (propDef.getCardinality() == Cardinality.SINGLE) {
+                result.put(JSON_PROPERTY_VALUE, getJSONValue(property.getValues().get(0)));
+            } else {
+                JSONArray values = new JSONArray();
+
+                for (Object value : property.getValues()) {
+                    values.add(getJSONValue(value));
+                }
+
+                result.put(JSON_PROPERTY_VALUE, values);
+            }
+        } else {
+            result.put(JSON_PROPERTY_DATATYPE, getJSONPropertyDataType(property));
+
+            if ((property.getValues() == null) || (property.getValues().size() == 0)) {
+                result.put(JSON_PROPERTY_VALUE, null);
+            } else if (property.getValues().size() == 1) {
+                JSONArray values = new JSONArray();
+
+                for (Object value : property.getValues()) {
+                    values.add(getJSONValue(value));
+                }
+
+                result.put(JSON_PROPERTY_VALUE, values);
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * Converts allowable actions.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(AllowableActions allowableActions) {
+        if (allowableActions == null) {
+            return null;
+        }
+
+        JSONObject result = new JSONObject();
+
+        Set<Action> actionSet = allowableActions.getAllowableActions();
+        for (Action action : Action.values()) {
+            result.put(action.value(), actionSet.contains(action));
+        }
+
+        return result;
+    }
+
+    /**
+     * Converts an ACL.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(Acl acl) {
+        if ((acl == null) || (acl.getAces() == null)) {
+            return null;
+        }
+
+        JSONArray aceObjects = new JSONArray();
+
+        for (Ace ace : acl.getAces()) {
+            JSONArray permissions = new JSONArray();
+            if (ace.getPermissions() != null) {
+                for (String p : ace.getPermissions()) {
+                    permissions.add(p);
+                }
+            }
+
+            JSONObject aceObject = new JSONObject();
+            JSONObject principalObjecy = new JSONObject();
+            principalObjecy.put(JSON_ACE_PRINCIPAL_ID, ace.getPrincipalId());
+            aceObject.put(JSON_ACE_PRINCIPAL, principalObjecy);
+            aceObject.put(JSON_ACE_PERMISSIONS, permissions);
+            aceObject.put(JSON_ACE_IS_DIRECT, ace.isDirect());
+
+            aceObjects.add(aceObject);
+        }
+
+        JSONObject result = new JSONObject();
+        result.put(JSON_ACL_ACES, aceObjects);
+        result.put(JSON_ACL_IS_EXACT, acl.isExact());
+
+        return result;
+    }
+
+    /**
+     * Converts a rendition.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(RenditionData rendition) {
+        if (rendition == null) {
+            return null;
+        }
+
+        JSONObject result = new JSONObject();
+
+        result.put(JSON_RENDITION_STREAM_ID, rendition.getStreamId());
+        result.put(JSON_RENDITION_MIMETYPE, rendition.getMimeType());
+        result.put(JSON_RENDITION_LENGTH, rendition.getBigLength());
+        result.put(JSON_RENDITION_KIND, rendition.getKind());
+        result.put(JSON_RENDITION_TITLE, rendition.getTitle());
+        result.put(JSON_RENDITION_HEIGHT, rendition.getBigHeight());
+        result.put(JSON_RENDITION_WIDTH, rendition.getBigWidth());
+        result.put(JSON_RENDITION_DOCUMENT_ID, rendition.getRenditionDocumentId());
+
+        return result;
+    }
+
+    /**
+     * Converts a query object list.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(ObjectList list) {
+        JSONObject result = new JSONObject();
+
+        if (list != null) {
+            JSONArray objects = new JSONArray();
+            if (list.getObjects() != null) {
+                for (ObjectData object : list.getObjects()) {
+                    objects.add(convert(object, null));
+                }
+            }
+
+            result.put(JSON_OBJECTLIST_OBJECTS, objects);
+
+            if (list.hasMoreItems() != null) {
+                result.put(JSON_OBJECTLIST_HAS_MORE_ITEMS, list.hasMoreItems());
+            }
+            if (list.getNumItems() != null) {
+                result.put(JSON_OBJECTLIST_NUM_ITEMS, list.getNumItems());
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * Converts an object in a folder list.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(ObjectInFolderData objectInFolder, TypeCache typeCache) {
+        if ((objectInFolder == null) || (objectInFolder.getObject() == null)) {
+            return null;
+        }
+
+        JSONObject result = new JSONObject();
+        result.put(JSON_OBJECTINFOLDER_OBJECT, convert(objectInFolder.getObject(), typeCache));
+        if (objectInFolder.getPathSegment() != null) {
+            result.put(JSON_OBJECTINFOLDER_PATH_SEGMENT, objectInFolder.getPathSegment());
+        }
+
+        return result;
+    }
+
+    /**
+     * Converts a folder list.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(ObjectInFolderList objectInFolderList, TypeCache typeCache) {
+        if (objectInFolderList == null) {
+            return null;
+        }
+
+        JSONObject result = new JSONObject();
+
+        if (objectInFolderList.getObjects() != null) {
+            JSONArray objects = new JSONArray();
+
+            for (ObjectInFolderData object : objectInFolderList.getObjects()) {
+                objects.add(convert(object, typeCache));
+            }
+
+            result.put(JSON_OBJECTINFOLDERLIST_OBJECTS, objects);
+        }
+
+        if (objectInFolderList.hasMoreItems() != null) {
+            result.put(JSON_OBJECTINFOLDERLIST_HAS_MORE_ITEMS, objectInFolderList.hasMoreItems());
+        }
+        if (objectInFolderList.getNumItems() != null) {
+            result.put(JSON_OBJECTINFOLDERLIST_NUM_ITEMS, objectInFolderList.getNumItems());
+        }
+
+        return result;
+    }
+
+    /**
+     * Converts a folder container.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(ObjectInFolderContainer container, TypeCache typeCache) {
+        if (container == null) {
+            return null;
+        }
+
+        JSONObject result = new JSONObject();
+        result.put(JSON_OBJECTINFOLDERCONTAINER_OBJECT, convert(container.getObject(), typeCache));
+
+        if ((container.getChildren() != null) && (container.getChildren().size() > 0)) {
+            JSONArray children = new JSONArray();
+            for (ObjectInFolderContainer descendant : container.getChildren()) {
+                children.add(JSONConverter.convert(descendant, typeCache));
+            }
+
+            result.put(JSON_OBJECTINFOLDERCONTAINER_CHILDREN, children);
+        }
+
+        return result;
+    }
+
+    /**
+     * Converts an object parent.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(ObjectParentData parent, TypeCache typeCache) {
+        if ((parent == null) || (parent.getObject() == null)) {
+            return null;
+        }
+
+        JSONObject result = new JSONObject();
+        result.put(JSON_OBJECTPARENTS_OBJECT, convert(parent.getObject(), typeCache));
+        if (parent.getRelativePathSegment() != null) {
+            result.put(JSON_OBJECTPARENTS_RELATIVE_PATH_SEGMENT, parent.getRelativePathSegment());
+        }
+
+        return result;
+    }
+
+    /**
+     * Converts a type definition.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(TypeDefinition type) {
+        if (type == null) {
+            return null;
+        }
+
+        JSONObject result = new JSONObject();
+        result.put(JSON_TYPE_ID, type.getId());
+        result.put(JSON_TYPE_LOCALNAME, type.getLocalName());
+        result.put(JSON_TYPE_LOCALNAMESPACE, type.getLocalNamespace());
+        result.put(JSON_TYPE_DISPLAYNAME, type.getDisplayName());
+        result.put(JSON_TYPE_QUERYNAME, type.getQueryName());
+        result.put(JSON_TYPE_DESCRIPTION, type.getDescription());
+        result.put(JSON_TYPE_BASE_ID, type.getBaseTypeId().value());
+        result.put(JSON_TYPE_PARENT_ID, type.getParentTypeId());
+        result.put(JSON_TYPE_CREATABLE, type.isCreatable());
+        result.put(JSON_TYPE_FILEABLE, type.isFileable());
+        result.put(JSON_TYPE_QUERYABLE, type.isQueryable());
+        result.put(JSON_TYPE_FULLTEXT_INDEXED, type.isFulltextIndexed());
+        result.put(JSON_TYPE_INCLUDE_IN_SUPERTYPE_QUERY, type.isIncludedInSupertypeQuery());
+        result.put(JSON_TYPE_CONTROLABLE_POLICY, type.isControllablePolicy());
+        result.put(JSON_TYPE_CONTROLABLE_ACL, type.isControllableAcl());
+
+        if (type instanceof DocumentTypeDefinition) {
+            result.put(JSON_TYPE_VERSIONABLE, ((DocumentTypeDefinition) type).isVersionable());
+            result.put(JSON_TYPE_CONTENTSTREAM_ALLOWED, ((DocumentTypeDefinition) type).getContentStreamAllowed()
+                    .value());
+        }
+
+        if (type instanceof RelationshipTypeDefinition) {
+            result.put(JSON_TYPE_ALLOWED_SOURCE_TYPES,
+                    getJSONArrayFromList(((RelationshipTypeDefinition) type).getAllowedSourceTypeIds()));
+            result.put(JSON_TYPE_ALLOWED_TARGET_TYPES,
+                    getJSONArrayFromList(((RelationshipTypeDefinition) type).getAllowedTargetTypeIds()));
+        }
+
+        if ((type.getPropertyDefinitions() != null) && (!type.getPropertyDefinitions().isEmpty())) {
+            JSONObject propertyDefs = new JSONObject();
+
+            for (PropertyDefinition<?> pd : type.getPropertyDefinitions().values()) {
+                propertyDefs.put(pd.getId(), convert(pd));
+            }
+
+            result.put(JSON_TYPE_PROPERTY_DEFINITIONS, propertyDefs);
+        }
+
+        return result;
+    }
+
+    /**
+     * Converts a property type definition.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(PropertyDefinition<?> propertyDef) {
+        if (propertyDef == null) {
+            return null;
+        }
+
+        JSONObject result = new JSONObject();
+        result.put(JSON_PROPERTYTYPE_ID, propertyDef.getId());
+        result.put(JSON_PROPERTYTYPE_LOCALNAME, propertyDef.getLocalName());
+        result.put(JSON_PROPERTYTYPE_LOCALNAMESPACE, propertyDef.getLocalName());
+        result.put(JSON_PROPERTYTYPE_DISPLAYNAME, propertyDef.getDisplayName());
+        result.put(JSON_PROPERTYTYPE_QUERYNAME, propertyDef.getQueryName());
+        result.put(JSON_PROPERTYTYPE_DESCRIPTION, propertyDef.getDescription());
+        result.put(JSON_PROPERTYTYPE_PROPERTY_TYPE, propertyDef.getPropertyType().value());
+        result.put(JSON_PROPERTYTYPE_CARDINALITY, propertyDef.getCardinality().value());
+        result.put(JSON_PROPERTYTYPE_UPDATABILITY, propertyDef.getUpdatability().value());
+        result.put(JSON_PROPERTYTYPE_INHERITED, propertyDef.isInherited());
+        result.put(JSON_PROPERTYTYPE_REQUIRED, propertyDef.isRequired());
+        result.put(JSON_PROPERTYTYPE_REQUIRED, propertyDef.isQueryable());
+        result.put(JSON_PROPERTYTYPE_OPENCHOICE, propertyDef.isOpenChoice());
+
+        // TODO: add type specific details
+        // TODO: add choice
+
+        return result;
+    }
+
+    /**
+     * Converts a type definition list.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(TypeDefinitionList list) {
+        if (list == null) {
+            return null;
+        }
+
+        JSONObject result = new JSONObject();
+
+        if (list.getList() != null) {
+            JSONArray objects = new JSONArray();
+
+            for (TypeDefinition type : list.getList()) {
+                objects.add(convert(type));
+            }
+
+            result.put(JSON_TYPESLIST_TYPES, objects);
+        }
+
+        result.put(JSON_TYPESLIST_HAS_MORE_ITEMS, list.hasMoreItems());
+        result.put(JSON_TYPESLIST_NUM_ITEMS, list.getNumItems());
+
+        return result;
+    }
+
+    /**
+     * Converts a type definition container.
+     */
+    @SuppressWarnings("unchecked")
+    public static JSONObject convert(TypeDefinitionContainer container) {
+        if (container == null) {
+            return null;
+        }
+
+        JSONObject result = new JSONObject();
+        result.put(JSON_TYPESCONTAINER_TYPE, convert(container.getTypeDefinition()));
+
+        if ((container.getChildren() != null) && (container.getChildren().size() > 0)) {
+            JSONArray children = new JSONArray();
+            for (TypeDefinitionContainer child : container.getChildren()) {
+                children.add(JSONConverter.convert(child));
+            }
+
+            result.put(JSON_TYPESCONTAINER_CHILDREN, children);
+        }
+
+        return result;
+    }
+
+    // -----------------------------------------------------------------
+
+    public static String getJSONStringValue(Object obj) {
+        if (obj == null) {
+            return null;
+        }
+
+        return obj.toString();
+    }
+
+    public static Object getJSONValue(Object value) {
+        if (value instanceof GregorianCalendar) {
+            return ((GregorianCalendar) value).getTimeInMillis();
+        }
+
+        return value;
+    }
+
+    @SuppressWarnings("unchecked")
+    public static JSONArray getJSONArrayFromList(List<?> list) {
+        if (list == null) {
+            return null;
+        }
+
+        JSONArray result = new JSONArray();
+        result.addAll(list);
+
+        return result;
+    }
+
+    public static String getJSONPropertyDataType(PropertyData<?> property) {
+        if (property instanceof PropertyBoolean) {
+            return PropertyType.BOOLEAN.value();
+        } else if (property instanceof PropertyId) {
+            return PropertyType.ID.value();
+        } else if (property instanceof PropertyInteger) {
+            return PropertyType.INTEGER.value();
+        } else if (property instanceof PropertyDateTime) {
+            return PropertyType.DATETIME.value();
+        } else if (property instanceof PropertyDecimal) {
+            return PropertyType.DECIMAL.value();
+        } else if (property instanceof PropertyHtml) {
+            return PropertyType.HTML.value();
+        } else if (property instanceof PropertyString) {
+            return PropertyType.STRING.value();
+        } else if (property instanceof PropertyUri) {
+            return PropertyType.URI.value();
+        }
+
+        return null;
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ExceptionHelper.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ExceptionHelper.java?rev=1094397&r1=1094396&r2=1094397&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ExceptionHelper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ExceptionHelper.java Mon Apr 18 09:29:45 2011
@@ -57,9 +57,9 @@ public class ExceptionHelper {
     /**
      * Returns the stack trace as DOM node.
      */
-    public static Node getStacktraceAsNode(Exception ex) {
+    public static Node getStacktraceAsNode(Throwable t) {
         try {
-            String st = getStacktraceAsString(ex);
+            String st = getStacktraceAsString(t);
             if (st != null) {
                 DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
                 DocumentBuilder docBuilder = dbfac.newDocumentBuilder();

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml?rev=1094397&r1=1094396&r2=1094397&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml Mon Apr 18 09:29:45 2011
@@ -51,6 +51,16 @@
 		</init-param>
 		<load-on-startup>2</load-on-startup>
 	</servlet>
+	
+	<servlet>
+		<servlet-name>cmisbrowser</servlet-name>
+		<servlet-class>org.apache.chemistry.opencmis.server.impl.browser.CmisBrowserBindingServlet</servlet-class>
+		<init-param>
+			<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>
@@ -63,6 +73,11 @@
 		<url-pattern>/atom/*</url-pattern>
 	</servlet-mapping>
 
+	<servlet-mapping>
+		<servlet-name>cmisbrowser</servlet-name>
+		<url-pattern>/browser/*</url-pattern>
+	</servlet-mapping>
+
 	<session-config>
 		<session-timeout>60</session-timeout>
 	</session-config>

Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/css/opencmis.css
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/css/opencmis.css?rev=1094397&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/css/opencmis.css (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/css/opencmis.css Mon Apr 18 09:29:45 2011
@@ -0,0 +1,63 @@
+@CHARSET "UTF-8";
+
+body {
+  font-family: Verdana, arial, sans-serif;
+  color: black;
+  font-size: 12px;
+}
+
+h1 {
+  font-size: 24px;
+  line-height: normal;
+  font-weight: bold;
+  background-color: #f0f0f0;
+  color: #003366;
+   border-bottom: 1px solid #3c78b5;
+  padding: 2px;
+  margin: 4px 0px 4px 0px;
+}
+
+h2 {
+  font-size: 18px;
+  line-height: normal;
+  font-weight: bold;
+  background-color: #f0f0f0;
+   border-bottom: 1px solid #3c78b5;
+  padding: 2px;
+  margin: 4px 0px 4px 0px;
+}
+
+h3 {
+  font-size: 14px;
+  line-height: normal;
+  font-weight: bold;
+  background-color: #f0f0f0;
+  padding: 2px;
+  margin: 4px 0px 4px 0px;
+}
+
+h4 {
+  font-size: 12px;
+  line-height: normal;
+  font-weight: bold;
+  background-color: #f0f0f0;
+  padding: 2px;
+  margin: 4px 0px 4px 0px;
+}
+
+HR {
+  color: 3c78b5;
+  height: 1;
+}
+
+th  {
+    border: 1px solid #ccc;
+    padding: 2px 4px 2px 4px;
+    background: #f0f0f0;
+    text-align: center;
+}
+
+td  {
+    border: 1px solid #ccc;
+    padding: 3px 4px 3px 4px;
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/css/opencmis.css
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/images/asf_logo.png
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/images/asf_logo.png?rev=1094397&view=auto
==============================================================================
Binary file - no diff available.

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/images/asf_logo.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/images/chemistry_logo_small.png
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/images/chemistry_logo_small.png?rev=1094397&view=auto
==============================================================================
Binary file - no diff available.

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/images/chemistry_logo_small.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/index.html
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/index.html?rev=1094397&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/index.html (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/index.html Mon Apr 18 09:29:45 2011
@@ -0,0 +1,55 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!-- 
+/*
+ * 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.
+ */
+-->
+<html>
+<head>
+<title>OpenCMIS Browser Binding</title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<link rel="stylesheet" type="text/css" href="css/opencmis.css"/>
+</head>
+<body>
+<a href="http://chemistry.apache.org"><img alt="Apache Chemistry Logo" title="Apache Chemistry Logo" src="images/chemistry_logo_small.png" /></a>
+<h1>Apache Chemistry OpenCMIS</h1>
+
+<br/>
+<h2>AtomPub binding</h2>
+<div><a href="atom">AtomPub service document</a></div>
+
+<br/>
+<h2>Web Services binding</h2>
+<div><a href="services/RepositoryService">Web Services overview</a></div>
+
+<br/>
+<h2>Browser binding</h2>
+<div><a href="browser">Browser binding service URL</a></div>
+
+<br/>
+<h2>Web interface</h2>
+<div><a href="web">OpenCMIS web interface</a></div>
+
+<br/>
+<h2>License</h2>
+<a href="http://www.apache.org"><img alt="ASF Logo" title="ASF Logo" src="images/asf_logo.png" align="right"/></a>
+<div>This software is licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0.html">Apache 2.0 License</a>.</div>
+<br/>
+
+</body>
+</html>
\ No newline at end of file

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/index.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/createdocument.html
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/createdocument.html?rev=1094397&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/createdocument.html (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/createdocument.html Mon Apr 18 09:29:45 2011
@@ -0,0 +1,135 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!-- 
+/*
+ * 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.
+ */
+-->
+<html>
+<head>
+<title>OpenCMIS Browser Binding createDocument Demo</title>
+<link rel="stylesheet" type="text/css" href="../css/opencmis.css"/>
+<style type="text/css">
+.box {
+	border-width: 1px;
+	border-style: solid;
+	width: 100%;
+	padding: 3px;
+}
+
+td {
+	padding: 5px;
+}
+
+</style>
+<script type="text/javascript" src="opencmis.js"></script>
+<script type="text/javascript">
+var repositoryUrl;
+var rootFolderUrl;
+var lastTransaction;
+
+function loadRepositoryInfos(infos) {
+    for(repId in infos) {
+        var ri = infos[repId];		
+
+        // the InMemory repository has only one repository
+        repositoryUrl = ri.repositoryUrl;
+        rootFolderUrl = ri.rootFolderUrl; 
+    }
+}
+
+function createDocument() {
+    var createForm = document.getElementById('createForm');
+    var docname = createForm["propertyValue[0]"].value;
+    document.getElementById('info').innerHTML = "Creating " + docname + " ...";
+
+    createForm.action = rootFolderUrl + createForm.folder.value;
+    lastTransaction = createGUID();
+    createForm.transaction.value = lastTransaction;
+ 
+    return true;
+}
+
+function createDocumentCallback() {
+    if(lastTransaction) {
+        document.getElementById('info').innerHTML = 'Transaction: ' + lastTransaction
+
+        var script1 = document.createElement("script");
+        script1.setAttribute("src", repositoryUrl + "?selector=lastResult&clientToken=showNewDocumentId&transaction="+lastTransaction);
+        script1.setAttribute("type","text/javascript");                
+        document.body.appendChild(script1);
+    }
+}
+
+function showNewDocumentId(result) {
+    if(result.objectId) {
+        alert("New document id: " + result.objectId + "\nCode: " + result.code);
+    }
+    else {
+        alert("Error: " + result.message + "\nException: " + result.exception + "\nCode: " + result.code);
+    }
+}
+</script>
+</head>
+<body>
+<h1>OpenCMIS Browser Binding - Create Demo</h1>
+<br/>
+<h2>Create Document</h2>
+
+<form id="createForm" action="" method="POST" target="result" enctype="multipart/form-data" onsubmit="return createDocument()">
+<input name="cmisaction" type="hidden" value="createDocument" />
+<input name="transaction" type="hidden" value="" />
+<table>
+<tr>
+    <td>Folder:</td>
+    <td><input name="folder" type="text" size="100" maxlength="1000" value="/"></td>
+</tr>
+<tr>
+    <td>Name:</td>
+    <td><input id="docname" name="propertyValue[0]" type="text" size="100" maxlength="100" value="document"></td>
+    <input name="propertyId[0]" type="hidden" value="cmis:name" />
+</tr>
+<tr>
+    <td>Object Type:</td>
+    <td><input name="propertyValue[1]" type="text" size="100" maxlength="100" value="cmis:document"></td>
+    <input name="propertyId[1]" type="hidden" value="cmis:objectTypeId" />
+</tr>
+<tr>
+    <td>File name:</td>
+    <td><input name="filename" type="text" size="30" maxlength="30" value=""> (if left blank the orignal file name is used)</td>
+</tr>
+<tr>
+    <td>Content type:</td>
+    <td><input name="contentType" type="text" size="30" maxlength="30" value=""> (if left blank the content type is determined by the browser)</td>
+</tr>
+<tr>
+	<td>File:</td>
+	<td><input name="content" type="file"></td>
+</tr>
+<tr>
+    <td></td>
+    <td><input type="submit" value="Create" /></td>
+</tr>
+</table>
+</form>
+
+<div id="info"></div>
+<iframe name="result" style="border:2px;width:800px;height:400px;" onload="createDocumentCallback()"></iframe>
+
+<script type="text/javascript" src="../browser?clientToken=loadRepositoryInfos"></script>
+</body>
+</html>
\ No newline at end of file

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/createdocument.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/createfolder.html
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/createfolder.html?rev=1094397&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/createfolder.html (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/createfolder.html Mon Apr 18 09:29:45 2011
@@ -0,0 +1,122 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!-- 
+/*
+ * 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.
+ */
+-->
+<html>
+<head>
+<title>OpenCMIS Browser Binding createFolder Demo</title>
+<link rel="stylesheet" type="text/css" href="../css/opencmis.css"/>
+<style type="text/css">
+.box {
+	border-width: 1px;
+	border-style: solid;
+	width: 100%;
+	padding: 3px;
+}
+
+td {
+	padding: 5px;
+}
+</style>
+<script type="text/javascript" src="opencmis.js"></script>
+<script type="text/javascript">
+var repositoryUrl;
+var rootFolderUrl;
+var lastTransaction;
+
+function loadRepositoryInfos(infos) {
+    for(repId in infos) {
+        var ri = infos[repId];		
+
+        // the InMemory repository has only one repository
+        repositoryUrl = ri.repositoryUrl;
+        rootFolderUrl = ri.rootFolderUrl; 
+    }
+}
+
+function createFolder() {
+    var createForm = document.getElementById('createForm');
+    var foldername = createForm["propertyValue[0]"].value;
+    document.getElementById('info').innerHTML = "Creating " + foldername + " ...";
+
+    createForm.action = rootFolderUrl + createForm.folder.value;
+    lastTransaction = createGUID();
+    createForm.transaction.value = lastTransaction;
+ 
+    return true;
+}
+
+function createFolderCallback() {
+    if(lastTransaction) {
+        document.getElementById('info').innerHTML = 'Transaction: ' + lastTransaction
+
+        var script1 = document.createElement("script");
+        script1.setAttribute("src", repositoryUrl + "?selector=lastResult&clientToken=showNewFolderId&transaction="+lastTransaction);
+        script1.setAttribute("type","text/javascript");                
+        document.body.appendChild(script1);
+    }
+}
+
+function showNewFolderId(result) {
+    if(result.objectId) {
+        alert("New folder id: " + result.objectId + "\nCode: " + result.code);
+    }
+    else {
+        alert("Error: " + result.message + "\nException: " + result.exception + "\nCode: " + result.code);
+    }
+}
+</script>
+</head>
+<body>
+<h1>OpenCMIS Browser Binding - Create Demo</h1>
+<br/>
+<h2>Create Folder</h2>
+
+<form id="createForm" action="" method="POST" target="result" onsubmit="return createFolder()">
+<input name="cmisaction" type="hidden" value="createFolder" />
+<input name="transaction" type="hidden" value="" />
+<table>
+<tr>
+    <td>Folder:</td>
+    <td><input name="folder" type="text" size="100" maxlength="1000" value="/"></td>
+</tr>
+<tr>
+    <td>Name:</td>
+    <td><input id="docname" name="propertyValue[0]" type="text" size="100" maxlength="100" value="folder"></td>
+    <input name="propertyId[0]" type="hidden" value="cmis:name" />
+</tr>
+<tr>
+    <td>Object Type:</td>
+    <td><input name="propertyValue[1]" type="text" size="100" maxlength="100" value="cmis:folder"></td>
+    <input name="propertyId[1]" type="hidden" value="cmis:objectTypeId" />
+</tr>
+<tr>
+    <td></td>
+    <td><input type="submit" value="Create" /></td>
+</tr>
+</table>
+</form>
+
+<div id="info"></div>
+<iframe name="result" style="border:2px;width:800px;height:400px;" onload="createFolderCallback()"></iframe>
+
+<script type="text/javascript" src="../browser?clientToken=loadRepositoryInfos"></script>
+</body>
+</html>
\ No newline at end of file

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/createfolder.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/demo.html
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/demo.html?rev=1094397&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/demo.html (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/demo.html Mon Apr 18 09:29:45 2011
@@ -0,0 +1,209 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!-- 
+/*
+ * 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.
+ */
+-->
+<html>
+<head>
+<title>OpenCMIS Browser Binding Demo</title>
+<link rel="stylesheet" type="text/css" href="../css/opencmis.css"/>
+<style type="text/css">
+.box {
+	border-width: 1px;
+	border-style: solid;
+	width: 100%;
+	padding: 3px;
+}
+
+td {
+	padding: 5px;
+}
+</style>
+<script type="text/javascript">
+var repositoryUrl;
+var rootFolderUrl;
+
+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>Repository URL:</td><td>' + ri.repositoryUrl + '</td></tr>' +
+            '<tr><td>Root folder URL:</td><td>' + ri.rootFolderUrl + '</td></tr>' +
+            '</table>';
+
+        // the InMemory repository has only one repository
+        repositoryUrl = ri.repositoryUrl;
+        rootFolderUrl = ri.rootFolderUrl; 
+	}
+
+    var rootFolder = "/";
+
+    document.getElementById('queryForm').action = repositoryUrl;
+	
+    var script1 = document.createElement("script");        
+    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", rootFolderUrl + rootFolder + "?selector=children&clientToken=printChildren");
+    script2.setAttribute("type","text/javascript");                
+    document.body.appendChild(script2);
+
+    var script3 = document.createElement("script");        
+    script3.setAttribute("src", repositoryUrl + "?selector=typeChildren&clientToken=printTypes");
+    script3.setAttribute("type","text/javascript");                
+    document.body.appendChild(script3);
+}
+
+function printObject(obj) {
+    var id = obj.properties["cmis:objectId"].value;
+    var name = obj.properties["cmis:name"].value;
+
+    var s = '<h2>Object "' + name + '" (' + id + ')</h2>';
+
+    s = s + '<h3>Properties</h3>';
+    s = s + '<table>';
+	
+    for(propertyId in obj.properties) {
+        var property = obj.properties[propertyId];
+        s = s + '<tr><td>' + propertyId + '</td>';
+        s = s + '<td>' + property.displayName + '</td>';
+        s = s + '<td>' + property.type + '</td>';
+        s = s + '<td>' + property.cardinality + '</td>';
+
+        if(property.type == 'datetime') {
+            s = s + '<td>' + (new Date(property.value)) + '</td></tr>';
+        } else {
+            s = s + '<td>' + property.value + '</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 index in children.objects) {
+        var object = children.objects[index].object;
+
+        var name = object.properties["cmis:name"].value;
+        var type = object.properties["cmis:objectTypeId"].value;
+        var mimetype = "";
+        var size = "";
+        var createdBy = object.properties["cmis:createdBy"].value;
+        var creationDate = new Date(object.properties["cmis:creationDate"].value);
+        var id = object.properties["cmis:objectId"].value;
+        var link = "";
+
+        if(object.properties["cmis:baseTypeId"].value == "cmis:document") {
+            if(object.properties["cmis:contentStreamLength"]) {
+                size = object.properties["cmis:contentStreamLength"].value;
+            } else {
+                size = "";
+            }
+
+            if(object.properties["cmis:contentStreamMimeType"]) {           	 
+                mimetype = object.properties["cmis:contentStreamMimeType"].value;
+                link = encodeURI(rootFolderUrl + '?objectId=' + id + '&selector=content');
+            } else {
+            	mimetype = "";
+            	link = "";
+            }
+        }
+
+        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;
+}
+
+function printTypes(types) {
+    var s = '<h2>Base Types</h2>';
+    
+    for(var index in types.types) {
+        var type = types.types[index];
+
+        s = s + '<h3>' + type.id + '</h3>';
+        s = s + '<ul>';
+
+        for(var propId in type.propertyDefinitions) {
+            var propType = type.propertyDefinitions[propId];
+            s = s + '<li>' + propType.id + '</li>';
+        }
+
+        s = s + '</ul>';
+    }
+    
+    document.getElementById('typeInfo').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>
+<br />
+<div id="typeInfo" class="box">typeInfo</div>
+<br />
+<div id="query" class="box">
+<h2>Query</h2>
+<form id="queryForm" action="" method="POST">
+<input name="cmisaction" type="hidden" value="query" />
+<table>
+<tr><td>Query:</td><td><input name="q" type="text" size="100" maxlength="1000" value="SELECT * FROM cmis:document"></td></tr>
+<tr><td>Max Items:</td><td><input name="maxItems" type="text" size="4" maxlength="8" value="100"></td></tr>
+<tr><td>Skip Count:</td><td><input name="skipCount" type="text" size="4" maxlength="8" value="0"></td></tr>
+<tr><td></td><td><input type="submit" value="Go" /></td></tr>
+</table>
+</form>
+</div>
+
+<script type="text/javascript" src="../browser?clientToken=printRepositoryInfos"></script>
+</body>
+</html>
\ No newline at end of file

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/demo.html
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message