chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1044699 - in /incubator/chemistry/opencmis-browser-binding/trunk: ./ src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/ src/main/webapp/
Date Sat, 11 Dec 2010 20:03:09 GMT
Author: fmui
Date: Sat Dec 11 20:03:08 2010
New Revision: 1044699

URL: http://svn.apache.org/viewvc?rev=1044699&view=rev
Log:
browser binding: implemented createDocument ... well, sort of ...

Added:
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java   (with props)
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/TypeCache.java   (with props)
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/create.html   (with props)
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/result.html   (with props)
Removed:
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/UploadHttpServletRequestWrapper.java
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverterTypeCache.java
Modified:
    incubator/chemistry/opencmis-browser-binding/trunk/pom.xml
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/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/DiscoveryService.java
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/NavigationService.java
    incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.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/VersioningService.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/pom.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/pom.xml?rev=1044699&r1=1044698&r2=1044699&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/pom.xml (original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/pom.xml Sat Dec 11 20:03:08 2010
@@ -99,6 +99,11 @@
             <version>1.2.1</version>
         </dependency>
         <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.0</version>
+        </dependency>
+        <dependency>
              <groupId>com.googlecode.json-simple</groupId>
              <artifactId>json-simple</artifactId>
              <version>1.1</version>

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=1044699&r1=1044698&r2=1044699&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 Sat Dec 11 20:03:08 2010
@@ -21,18 +21,40 @@ package org.apache.chemistry.opencmis.se
 import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
 
 import java.io.IOException;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.data.Acl;
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
 import org.apache.chemistry.opencmis.commons.data.Properties;
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyBooleanImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDateTimeImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyHtmlImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIdImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriImpl;
 import org.apache.chemistry.opencmis.commons.server.CallContext;
 import org.apache.chemistry.opencmis.commons.server.CmisService;
 import org.apache.chemistry.opencmis.server.impl.CallContextImpl;
@@ -58,14 +80,17 @@ public class BrowserBindingUtils {
     public static final String SELECTOR_QUERY = "query";
     public static final String SELECTOR_VERSIONS = "versions";
 
+    public static final String ACTION_CREATEDOCUMENT = "createDocument";
     public static final String ACTION_QUERY = "query";
 
     public static final String PARAM_SELECTOR = "selector";
+    public static final String PARAM_REDIRECT = "redirect";
     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_ACTION = "cmisaction";
     public static final String FIELD_OBJECT_ID = "objectId";
+    public static final String FIELD_PROP_NAME = "property_name_";
+    public static final String FIELD_PROP_VALUE = "property_value_";
 
     public static final String CONTEXT_OBJECT_ID = "org.apache.chemistry.openmis.browserbinding.objectId";
     public static final String CONTEXT_OBJECT_TYPE_ID = "org.apache.chemistry.openmis.browserbinding.objectTypeId";
@@ -78,19 +103,23 @@ public class BrowserBindingUtils {
     /**
      * Compiles the base URL for links, collections and templates.
      */
-    public static UrlBuilder compileBaseUrl(HttpServletRequest request, String repositoryId) {
+    public static UrlBuilder compileBaseUrl(HttpServletRequest request) {
         UrlBuilder url = new UrlBuilder(request.getScheme(), request.getServerName(), request.getServerPort(), null);
 
         url.addPath(request.getContextPath());
         url.addPath(request.getServletPath());
 
-        if (repositoryId != null) {
-            url.addPathSegment(repositoryId);
-        }
-
         return url;
     }
 
+    public static UrlBuilder compileRepositoryUrl(HttpServletRequest request, String repositoryId) {
+        return compileBaseUrl(request).addPathSegment(repositoryId);
+    }
+
+    public static UrlBuilder compileRootUrl(HttpServletRequest request, String repositoryId) {
+        return compileRepositoryUrl(request, repositoryId).addPathSegment(BrowserBindingUtils.ROOT_PATH_FRAGMENT);
+    }
+
     /**
      * Returns the current CMIS path.
      */
@@ -176,6 +205,133 @@ public class BrowserBindingUtils {
         return (T) value;
     }
 
+    @SuppressWarnings("unchecked")
+    public static Properties createProperties(HttpServletRequest request, String typeId, TypeCache typeCache) {
+        Map<Integer, String> names = new HashMap<Integer, String>();
+        Map<Integer, String> values = new HashMap<Integer, String>();
+        int typeIdIndex = -1;
+
+        Map<String, String[]> fields = request.getParameterMap();
+        for (Map.Entry<String, String[]> field : fields.entrySet()) {
+            String fieldName = field.getKey().toLowerCase();
+
+            try {
+                if (fieldName.startsWith(FIELD_PROP_NAME)) {
+                    int index = Integer.parseInt(fieldName.substring(FIELD_PROP_NAME.length()));
+                    names.put(index, field.getValue()[0]);
+
+                    if (PropertyIds.OBJECT_TYPE_ID.equals(field.getValue()[0])) {
+                        typeIdIndex = index;
+                    }
+                } else if (fieldName.startsWith(FIELD_PROP_VALUE)) {
+                    int index = Integer.parseInt(fieldName.substring(FIELD_PROP_VALUE.length()));
+                    values.put(index, field.getValue()[0]);
+                }
+            } catch (NumberFormatException e) {
+            }
+        }
+
+        if ((typeId == null) && (typeIdIndex > -1)) {
+            // it's a create call -> find type id in properties
+            typeId = values.get(typeIdIndex);
+        }
+
+        TypeDefinition typeDef = typeCache.getTypeDefinition(typeId);
+        if (typeDef == null) {
+            throw new CmisInvalidArgumentException(PropertyIds.OBJECT_TYPE_ID + " not set!");
+        }
+
+        PropertiesImpl result = new PropertiesImpl();
+
+        for (Map.Entry<Integer, String> property : names.entrySet()) {
+            PropertyDefinition<?> propDef = typeDef.getPropertyDefinitions().get(property.getValue());
+            if (propDef == null) {
+                throw new CmisInvalidArgumentException(property.getValue() + " is unknown!");
+            }
+
+            String value = values.get(property.getKey());
+
+            PropertyData<?> propertyData = null;
+            switch (propDef.getPropertyType()) {
+            case STRING:
+                propertyData = new PropertyStringImpl(property.getValue(), value);
+                break;
+            case ID:
+                propertyData = new PropertyIdImpl(property.getValue(), value);
+                break;
+            case BOOLEAN:
+                propertyData = new PropertyBooleanImpl(property.getValue(), Boolean.valueOf(value));
+                break;
+            case INTEGER:
+                BigInteger valueInt = null;
+                try {
+                    valueInt = new BigInteger(value);
+                } catch (NumberFormatException e) {
+                    throw new CmisInvalidArgumentException(property.getValue() + " is not an integer value!");
+                }
+                propertyData = new PropertyIntegerImpl(property.getValue(), valueInt);
+                break;
+            case DECIMAL:
+                BigDecimal valueDec = null;
+                try {
+                    valueDec = new BigDecimal(value);
+                } catch (NumberFormatException e) {
+                    throw new CmisInvalidArgumentException(property.getValue() + " is not a decimal value!");
+                }
+                propertyData = new PropertyDecimalImpl(property.getValue(), valueDec);
+                break;
+            case DATETIME:
+                GregorianCalendar valueDate = new GregorianCalendar();
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
+                try {
+                    valueDate.setTime(sdf.parse(value));
+                } catch (ParseException e) {
+                    throw new CmisInvalidArgumentException(property.getValue() + " is not a datetime value!");
+                }
+                propertyData = new PropertyDateTimeImpl(property.getValue(), valueDate);
+                break;
+            case HTML:
+                propertyData = new PropertyHtmlImpl(property.getValue(), value);
+                break;
+            case URI:
+                propertyData = new PropertyUriImpl(property.getValue(), value);
+                break;
+            }
+
+            result.addProperty(propertyData);
+        }
+
+        return result;
+    }
+
+    public static List<String> createPolcies(HttpServletRequest request) {
+        return null;
+    }
+
+    public static Acl createAcl(HttpServletRequest request) {
+        return null;
+    }
+
+    public static Acl createAddAcl(HttpServletRequest request) {
+        return null;
+    }
+
+    public static Acl createRemoveAcl(HttpServletRequest request) {
+        return null;
+    }
+
+    public static ContentStream createContentStream(HttpServletRequest request) {
+        ContentStreamImpl result = null;
+
+        if (request instanceof POSTHttpServletRequestWrapper) {
+            POSTHttpServletRequestWrapper post = (POSTHttpServletRequestWrapper) request;
+            result = new ContentStreamImpl(post.getFileName(), BigInteger.valueOf(post.getSize()),
+                    post.getContentType(), post.getStream());
+        }
+
+        return result;
+    }
+
     /**
      * Writes JSON to the servlet response and adds a callback wrapper if
      * requested.

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=1044699&r1=1044698&r2=1044699&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 Sat Dec 11 20:03:08 2010
@@ -100,6 +100,8 @@ public class CmisBrowserBindingServlet e
                     DiscoveryService.class, "query");
             repositoryDispatcher.addResource(BrowserBindingUtils.ACTION_QUERY, Dispatcher.METHOD_POST,
                     DiscoveryService.class, "query");
+            repositoryDispatcher.addResource(BrowserBindingUtils.ACTION_CREATEDOCUMENT, Dispatcher.METHOD_POST,
+                    ObjectService.class, "createDocument");
 
             rootDispatcher.addResource(BrowserBindingUtils.SELECTOR_OBJECT, Dispatcher.METHOD_GET, ObjectService.class,
                     "getObject");
@@ -115,6 +117,8 @@ public class CmisBrowserBindingServlet e
                     NavigationService.class, "getObjectParents");
             rootDispatcher.addResource(BrowserBindingUtils.SELECTOR_VERSIONS, Dispatcher.METHOD_GET,
                     VersioningService.class, "getAllVersions");
+            rootDispatcher.addResource(BrowserBindingUtils.ACTION_CREATEDOCUMENT, Dispatcher.METHOD_POST,
+                    ObjectService.class, "createDocument");
         } catch (NoSuchMethodException e) {
             LOG.error("Cannot initialize dispatcher!", e);
         }
@@ -237,24 +241,24 @@ public class CmisBrowserBindingServlet e
                             response);
                 }
             } else if (Dispatcher.METHOD_POST.equals(method)) {
-                UploadHttpServletRequestWrapper uploadRequest = new UploadHttpServletRequestWrapper(request);
+                POSTHttpServletRequestWrapper postRequest = new POSTHttpServletRequestWrapper(request);
 
-                String action = HttpUtils.getStringParameter(uploadRequest, BrowserBindingUtils.FIELD_ACTION);
-                String objectId = HttpUtils.getStringParameter(uploadRequest, BrowserBindingUtils.FIELD_OBJECT_ID);
+                String action = HttpUtils.getStringParameter(postRequest, BrowserBindingUtils.FIELD_ACTION);
+                String objectId = HttpUtils.getStringParameter(postRequest, 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);
+                BrowserBindingUtils.prepareContext(context, callUrl, service, repositoryId, objectId, postRequest);
 
                 // dispatch
                 if (callUrl == CallUrl.REPOSITORY) {
                     methodFound = repositoryDispatcher.dispatch(action, method, context, service, repositoryId,
-                            request, response);
+                            postRequest, response);
                 } else if (callUrl == CallUrl.ROOT) {
-                    methodFound = rootDispatcher.dispatch(action, method, context, service, repositoryId, request,
+                    methodFound = rootDispatcher.dispatch(action, method, context, service, repositoryId, postRequest,
                             response);
                 }
             }

Modified: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/DiscoveryService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/DiscoveryService.java?rev=1044699&r1=1044698&r2=1044699&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/DiscoveryService.java (original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/DiscoveryService.java Sat Dec 11 20:03:08 2010
@@ -61,6 +61,7 @@ public class DiscoveryService {
             throw new CmisRuntimeException("Results are null!");
         }
 
+        response.setStatus(HttpServletResponse.SC_OK);
         BrowserBindingUtils.writeJSON(JSONConverter.convert(results), request, response);
     }
 }

Modified: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/NavigationService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/NavigationService.java?rev=1044699&r1=1044698&r2=1044699&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/NavigationService.java (original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/NavigationService.java Sat Dec 11 20:03:08 2010
@@ -38,7 +38,6 @@ import org.apache.chemistry.opencmis.com
 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.apache.chemistry.opencmis.server.impl.browser.json.JSONConverterTypeCache;
 import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 
@@ -70,9 +69,10 @@ public final class NavigationService {
             throw new CmisRuntimeException("Children are null!");
         }
 
-        JSONConverterTypeCache typeCache = new JSONConverterTypeCache(repositoryId, service);
+        TypeCache typeCache = new TypeCache(repositoryId, service);
         JSONObject jsonChildren = JSONConverter.convert(children, typeCache);
 
+        response.setStatus(HttpServletResponse.SC_OK);
         BrowserBindingUtils.writeJSON(jsonChildren, request, response);
     }
 
@@ -100,12 +100,13 @@ public final class NavigationService {
             throw new CmisRuntimeException("Descendants are null!");
         }
 
-        JSONConverterTypeCache typeCache = new JSONConverterTypeCache(repositoryId, service);
+        TypeCache typeCache = new TypeCache(repositoryId, service);
         JSONArray jsonDescendants = new JSONArray();
         for (ObjectInFolderContainer descendant : descendants) {
             jsonDescendants.add(JSONConverter.convert(descendant, typeCache));
         }
 
+        response.setStatus(HttpServletResponse.SC_OK);
         BrowserBindingUtils.writeJSON(jsonDescendants, request, response);
     }
 
@@ -133,12 +134,13 @@ public final class NavigationService {
             throw new CmisRuntimeException("Folder Tree are null!");
         }
 
-        JSONConverterTypeCache typeCache = new JSONConverterTypeCache(repositoryId, service);
+        TypeCache typeCache = new TypeCache(repositoryId, service);
         JSONArray jsonDescendants = new JSONArray();
         for (ObjectInFolderContainer descendant : folderTree) {
             jsonDescendants.add(JSONConverter.convert(descendant, typeCache));
         }
 
+        response.setStatus(HttpServletResponse.SC_OK);
         BrowserBindingUtils.writeJSON(jsonDescendants, request, response);
     }
 
@@ -165,12 +167,13 @@ public final class NavigationService {
             throw new CmisRuntimeException("Parents are null!");
         }
 
-        JSONConverterTypeCache typeCache = new JSONConverterTypeCache(repositoryId, service);
+        TypeCache typeCache = new TypeCache(repositoryId, service);
         JSONArray jsonParents = new JSONArray();
         for (ObjectParentData parent : parents) {
             jsonParents.add(JSONConverter.convert(parent, typeCache));
         }
 
+        response.setStatus(HttpServletResponse.SC_OK);
         BrowserBindingUtils.writeJSON(jsonParents, request, response);
     }
 }

Modified: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java?rev=1044699&r1=1044698&r2=1044699&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java (original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java Sat Dec 11 20:03:08 2010
@@ -27,6 +27,8 @@ import java.io.BufferedOutputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.math.BigInteger;
+import java.net.MalformedURLException;
+import java.net.URL;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -34,13 +36,16 @@ import javax.servlet.http.HttpServletRes
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.impl.Constants;
 import org.apache.chemistry.opencmis.commons.impl.ReturnVersion;
+import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
 import org.apache.chemistry.opencmis.commons.server.CallContext;
 import org.apache.chemistry.opencmis.commons.server.CmisService;
+import org.apache.chemistry.opencmis.commons.server.ObjectInfo;
 import org.apache.chemistry.opencmis.server.impl.browser.json.JSONConverter;
-import org.apache.chemistry.opencmis.server.impl.browser.json.JSONConverterTypeCache;
 import org.json.simple.JSONObject;
 
 public final class ObjectService {
@@ -48,6 +53,56 @@ public final class ObjectService {
     private static final int BUFFER_SIZE = 64 * 1024;
 
     /**
+     * createDocument.
+     */
+    public static void createDocument(CallContext context, CmisService service, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        // get parameters
+        String folderId = (String) context.get(BrowserBindingUtils.CONTEXT_OBJECT_ID);
+        VersioningState versioningState = getEnumParameter(request, Constants.PARAM_VERSIONIG_STATE,
+                VersioningState.class);
+        String redirect = getStringParameter(request, BrowserBindingUtils.PARAM_REDIRECT);
+        URL redirectUrl = null;
+        if (redirect != null) {
+            try {
+                redirectUrl = new URL(redirect);
+            } catch (MalformedURLException e) {
+                throw new CmisInvalidArgumentException("Redirect URL is invalid!");
+            }
+        }
+
+        TypeCache typeCache = new TypeCache(repositoryId, service);
+
+        String newObjectId = service.createDocument(repositoryId,
+                BrowserBindingUtils.createProperties(request,null, typeCache), folderId,
+                BrowserBindingUtils.createContentStream(request), versioningState,
+                BrowserBindingUtils.createPolcies(request), BrowserBindingUtils.createAddAcl(request),
+                BrowserBindingUtils.createRemoveAcl(request), null);
+
+        if (redirectUrl != null) {
+            UrlBuilder ub= new UrlBuilder(redirectUrl.toString());
+            ub.addParameter("cmis:objectId", newObjectId);
+            
+            response.sendRedirect(ub.toString());
+        } else {
+            ObjectInfo objectInfo = service.getObjectInfo(repositoryId, newObjectId);
+            if (objectInfo == null) {
+                throw new CmisRuntimeException("Object Info is missing!");
+            }
+
+            ObjectData object = objectInfo.getObject();
+            if (object == null) {
+                throw new CmisRuntimeException("Object is null!");
+            }
+
+            JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+
+            response.setStatus(HttpServletResponse.SC_OK);
+            BrowserBindingUtils.writeJSON(jsonObject, request, response);
+        }
+    }
+
+    /**
      * getObject.
      */
     public static void getObject(CallContext context, CmisService service, String repositoryId,
@@ -79,9 +134,10 @@ public final class ObjectService {
             throw new CmisRuntimeException("Object is null!");
         }
 
-        JSONConverterTypeCache typeCache = new JSONConverterTypeCache(repositoryId, service);
+        TypeCache typeCache = new TypeCache(repositoryId, service);
         JSONObject jsonObject = JSONConverter.convert(object, typeCache);
 
+        response.setStatus(HttpServletResponse.SC_OK);
         BrowserBindingUtils.writeJSON(jsonObject, request, response);
     }
 

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java?rev=1044699&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java Sat Dec 11 20:03:08 2010
@@ -0,0 +1,142 @@
+/*
+ * 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 POSTHttpServletRequestWrapper extends HttpServletRequestWrapper {
+    private boolean isMultipart;
+    private Map<String, String[]> parameters;
+    private String fileName;
+    private String contentType;
+    private long size;
+    private InputStream stream;
+
+    public POSTHttpServletRequestWrapper(HttpServletRequest request) throws Exception {
+        this(request, 4 * 1024 * 1024);
+    }
+
+    public POSTHttpServletRequestWrapper(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 {
+                    fileName = item.getName();
+                    contentType = (item.getContentType() == null ? "application/octet-stream" : item.getContentType());
+                    size = item.getSize();
+                    stream = item.getInputStream();
+                }
+            }
+        }
+    }
+
+    @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 String getFileName() {
+        return fileName;
+    }
+
+    public String getContentType() {
+        return contentType;
+    }
+
+    public long getSize() {
+        return size;
+    }
+
+    public InputStream getStream() {
+        return stream;
+    }
+}

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

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=1044699&r1=1044698&r2=1044699&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 Sat Dec 11 20:03:08 2010
@@ -34,7 +34,6 @@ import org.apache.chemistry.opencmis.com
 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.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.browser.json.JSONConverter;
@@ -52,13 +51,12 @@ public final class RepositoryService {
         // execute
         List<RepositoryInfo> infoDataList = service.getRepositoryInfos(null);
 
-        UrlBuilder baseUrl = BrowserBindingUtils.compileBaseUrl(request, null);
-
         JSONObject result = new JSONObject();
         for (RepositoryInfo ri : infoDataList) {
-            result.put(ri.getId(), JSONConverter.convert(ri, baseUrl));
+            result.put(ri.getId(), JSONConverter.convert(ri, request));
         }
 
+        response.setStatus(HttpServletResponse.SC_OK);
         BrowserBindingUtils.writeJSON(result, request, response);
     }
 
@@ -70,9 +68,8 @@ public final class RepositoryService {
         // execute
         RepositoryInfo ri = service.getRepositoryInfo(repositoryId, null);
 
-        UrlBuilder baseUrl = BrowserBindingUtils.compileBaseUrl(request, null);
-
-        BrowserBindingUtils.writeJSON(JSONConverter.convert(ri, baseUrl), request, response);
+        response.setStatus(HttpServletResponse.SC_OK);
+        BrowserBindingUtils.writeJSON(JSONConverter.convert(ri, request), request, response);
     }
 
     /**
@@ -90,6 +87,7 @@ public final class RepositoryService {
         TypeDefinitionList typeList = service.getTypeChildren(repositoryId, typeId, includePropertyDefinitions,
                 maxItems, skipCount, null);
 
+        response.setStatus(HttpServletResponse.SC_OK);
         BrowserBindingUtils.writeJSON(JSONConverter.convert(typeList), request, response);
     }
 
@@ -117,6 +115,7 @@ public final class RepositoryService {
             jsonTypeTree.add(JSONConverter.convert(container));
         }
 
+        response.setStatus(HttpServletResponse.SC_OK);
         BrowserBindingUtils.writeJSON(jsonTypeTree, request, response);
     }
 
@@ -131,6 +130,7 @@ public final class RepositoryService {
         // execute
         TypeDefinition type = service.getTypeDefinition(repositoryId, typeId, null);
 
+        response.setStatus(HttpServletResponse.SC_OK);
         BrowserBindingUtils.writeJSON(JSONConverter.convert(type), request, response);
     }
 }

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/TypeCache.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/TypeCache.java?rev=1044699&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/TypeCache.java (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/TypeCache.java Sat Dec 11 20:03:08 2010
@@ -0,0 +1,53 @@
+/*
+ * 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;
+
+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);
+        }
+
+        return type;
+    }
+
+    public TypeDefinition getTypeDefinitionForObject(String objectId) {
+        ObjectInfo info = service.getObjectInfo(repositoryId, objectId);
+        return getTypeDefinition(info.getTypeId());
+    }
+}

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

Modified: incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/VersioningService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/VersioningService.java?rev=1044699&r1=1044698&r2=1044699&view=diff
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/VersioningService.java (original)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/VersioningService.java Sat Dec 11 20:03:08 2010
@@ -32,7 +32,6 @@ import org.apache.chemistry.opencmis.com
 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.apache.chemistry.opencmis.server.impl.browser.json.JSONConverterTypeCache;
 import org.json.simple.JSONArray;
 
 public class VersioningService {
@@ -56,12 +55,13 @@ public class VersioningService {
             throw new CmisRuntimeException("Versions are null!");
         }
 
-        JSONConverterTypeCache typeCache = new JSONConverterTypeCache(repositoryId, service);
+        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);
     }
 }

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=1044699&r1=1044698&r2=1044699&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 Sat Dec 11 20:03:08 2010
@@ -71,12 +71,12 @@ public class JSONConstants {
 
     public final static String JSON_OBJECT_PROPERTIES = "properties";
     public final static String JSON_OBJECT_ALLOWABLE_ACTIONS = "allowableActions";
-    public final static String JSON_OBJECT_RELATIONSHIP = "relationship";
+    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_RENDITION = "rendition";
+    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";

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=1044699&r1=1044698&r2=1044699&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 Sat Dec 11 20:03:08 2010
@@ -22,6 +22,8 @@ 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;
@@ -57,8 +59,8 @@ import org.apache.chemistry.opencmis.com
 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.commons.impl.UrlBuilder;
 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;
 
@@ -74,7 +76,7 @@ public class JSONConverter extends JSONC
      * Converts a repository info object.
      */
     @SuppressWarnings("unchecked")
-    public static JSONObject convert(RepositoryInfo repositoryInfo, UrlBuilder baseUrl) {
+    public static JSONObject convert(RepositoryInfo repositoryInfo, HttpServletRequest request) {
         if (repositoryInfo == null) {
             return null;
         }
@@ -108,13 +110,10 @@ 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());
+        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;
     }
@@ -208,7 +207,7 @@ public class JSONConverter extends JSONC
      * Converts an object.
      */
     @SuppressWarnings("unchecked")
-    public static JSONObject convert(ObjectData object, JSONConverterTypeCache typeCache) {
+    public static JSONObject convert(ObjectData object, TypeCache typeCache) {
         if (object == null) {
             return null;
         }
@@ -249,7 +248,7 @@ public class JSONConverter extends JSONC
                 relationships.add(convert(relationship, typeCache));
             }
 
-            result.put(JSON_OBJECT_RELATIONSHIP, relationships);
+            result.put(JSON_OBJECT_RELATIONSHIPS, relationships);
         }
 
         // change event info
@@ -288,7 +287,7 @@ public class JSONConverter extends JSONC
                 renditions.add(convert(rendition));
             }
 
-            result.put(JSON_OBJECT_RENDITION, renditions);
+            result.put(JSON_OBJECT_RENDITIONS, renditions);
         }
 
         return result;
@@ -448,7 +447,7 @@ public class JSONConverter extends JSONC
      * Converts an object in a folder list.
      */
     @SuppressWarnings("unchecked")
-    public static JSONObject convert(ObjectInFolderData objectInFolder, JSONConverterTypeCache typeCache) {
+    public static JSONObject convert(ObjectInFolderData objectInFolder, TypeCache typeCache) {
         if ((objectInFolder == null) || (objectInFolder.getObject() == null)) {
             return null;
         }
@@ -466,7 +465,7 @@ public class JSONConverter extends JSONC
      * Converts a folder list.
      */
     @SuppressWarnings("unchecked")
-    public static JSONObject convert(ObjectInFolderList objectInFolderList, JSONConverterTypeCache typeCache) {
+    public static JSONObject convert(ObjectInFolderList objectInFolderList, TypeCache typeCache) {
         if (objectInFolderList == null) {
             return null;
         }
@@ -493,7 +492,7 @@ public class JSONConverter extends JSONC
      * Converts a folder container.
      */
     @SuppressWarnings("unchecked")
-    public static JSONObject convert(ObjectInFolderContainer container, JSONConverterTypeCache typeCache) {
+    public static JSONObject convert(ObjectInFolderContainer container, TypeCache typeCache) {
         if (container == null) {
             return null;
         }
@@ -517,7 +516,7 @@ public class JSONConverter extends JSONC
      * Converts an object parent.
      */
     @SuppressWarnings("unchecked")
-    public static JSONObject convert(ObjectParentData parent, JSONConverterTypeCache typeCache) {
+    public static JSONObject convert(ObjectParentData parent, TypeCache typeCache) {
         if ((parent == null) || (parent.getObject() == null)) {
             return null;
         }

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/create.html
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/create.html?rev=1044699&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/create.html (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/create.html Sat Dec 11 20:03:08 2010
@@ -0,0 +1,89 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<title>OpenCMIS Browser Binding Create Demo</title>
+<style type="text/css">
+body {
+	font-family: Arial, sans-serif;
+	font-size: 11pt;
+}
+
+.box {
+	border-width: 1px;
+	border-style: solid;
+	width: 100%;
+	padding: 3px;
+}
+
+td {
+	padding: 5px;
+}
+</style>
+<script type="text/javascript">
+var repositoryUrl;
+var rootFolderUrl;
+
+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 name = "doc" + (new Date()).getTime();
+
+    var createForm = document.getElementById('createForm');
+    var docname = createForm["property_value_0"].value;
+    document.getElementById('info').innerHTML = "Creating " + docname + " ...";
+
+    createForm.action = rootFolderUrl + createForm.folder.value;
+    createForm.redirect.value = location.href.substring(0, location.href.lastIndexOf('/')) + "/result.html"
+ 
+    return true;
+}
+</script>
+</head>
+<body>
+<h1>OpenCMIS Browser Binding - Create Demo</h1>
+
+<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="redirect" 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="property_value_0" type="text" size="100" maxlength="100" value="document"></td>
+    <input name="property_name_0" type="hidden" value="cmis:name" />
+</tr>
+<tr>
+    <td>Object Type:</td>
+    <td><input name="property_value_1" type="text" size="100" maxlength="100" value="cmis:document"></td>
+    <input name="property_name_1" type="hidden" value="cmis:objectTypeId" />
+</tr>
+<tr>
+	<td>File:</td>
+	<td><input name="file" 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:600px;height:400px;"></iframe>
+
+<script type="text/javascript" src="browser?clientToken=loadRepositoryInfos"></script>
+</body>
+</html>
\ No newline at end of file

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

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=1044699&r1=1044698&r2=1044699&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 Sat Dec 11 20:03:08 2010
@@ -112,9 +112,19 @@ function printChildren(children) {
         var link = "";
 
         if(object.properties["cmis:baseTypeId"].value == "cmis:document") {
-            size = object.properties["cmis:contentStreamLength"].value;
-            mimetype = object.properties["cmis:contentStreamMimeType"].value;
-            link = encodeURI(rootFolderUrl + '?objectId=' + id + '&selector=content');
+            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>';
@@ -153,8 +163,6 @@ function printTypes(types) {
     document.getElementById('typeInfo').innerHTML = s;
 }
 </script>
-
-
 </head>
 <body>
 <h1>OpenCMIS Browser Binding - Demo</h1>
@@ -180,7 +188,6 @@ function printTypes(types) {
 </form>
 </div>
 
-<script type="text/javascript"
-	src="browser?clientToken=printRepositoryInfos"></script>
+<script type="text/javascript" src="browser?clientToken=printRepositoryInfos"></script>
 </body>
 </html>
\ No newline at end of file

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=1044699&r1=1044698&r2=1044699&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 Sat Dec 11 20:03:08 2010
@@ -17,6 +17,7 @@
 
 <ul>
 <li><a href="demo.html">Demo Page</a></li>
+<li><a href="create.html">Create Document Demo Page</a></li>
 <li><a href="browser">Repository Infos</a></li>
 </ul>
 

Added: incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/result.html
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/result.html?rev=1044699&view=auto
==============================================================================
--- incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/result.html (added)
+++ incubator/chemistry/opencmis-browser-binding/trunk/src/main/webapp/result.html Sat Dec 11 20:03:08 2010
@@ -0,0 +1,23 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<script type="text/javascript">
+function getUrlParameter(param){
+    param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
+    var r1 = "[\\?&]" + param + "=([^&#]*)";
+    var r2 = new RegExp(r1);
+    var r3 = r2.exec(window.location.href);
+    if(r3 == null) {
+        return "";
+    } else {
+        return decodeURI(r3[1]);
+    }
+}
+</script>
+</head>
+<body>
+<script type="text/javascript">
+    parent.document.getElementById('info').innerHTML = "Documen id: " + getUrlParameter("cmis:objectId");
+</script>
+</body>
+</html>
\ No newline at end of file

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



Mime
View raw message