chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1198956 - /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/
Date Mon, 07 Nov 2011 21:44:31 GMT
Author: fmui
Date: Mon Nov  7 21:44:30 2011
New Revision: 1198956

URL: http://svn.apache.org/viewvc?rev=1198956&view=rev
Log:
more browser binding code - mostly untested

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/NavigationService.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.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/BrowserBindingUtils.java?rev=1198956&r1=1198955&r2=1198956&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java
Mon Nov  7 21:44:30 2011
@@ -83,6 +83,7 @@ public class BrowserBindingUtils {
     public static final String SELECTOR_CHILDREN = "children";
     public static final String SELECTOR_DESCENDANTS = "descendants";
     public static final String SELECTOR_PARENTS = "parents";
+    public static final String SELECTOR_PARENT = "parent";
     public static final String SELECTOR_FOLDER_TREE = "folder";
     public static final String SELECTOR_QUERY = "query";
     public static final String SELECTOR_VERSIONS = "versions";
@@ -91,6 +92,7 @@ public class BrowserBindingUtils {
     public static final String CMISACTION_CREATE_FOLDER = "createFolder";
     public static final String CMISACTION_CREATE_RELATIONSHIP = "createRelationship";
     public static final String CMISACTION_CREATE_POLICY = "createPolicy";
+    public static final String CMISACTION_DELETE_CONTENT = "deleteContent";
     public static final String CMISACTION_SET_CONTENT = "setContent";
     public static final String CMISACTION_DELETE = "delete";
     public static final String CMISACTION_DELETE_TREE = "deleteTree";

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.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/CmisBrowserBindingServlet.java?rev=1198956&r1=1198955&r2=1198956&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
Mon Nov  7 21:44:30 2011
@@ -22,8 +22,10 @@ import static org.apache.chemistry.openc
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_CREATE_DOCUMENT;
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_CREATE_FOLDER;
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_DELETE;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_DELETE_CONTENT;
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_DELETE_TREE;
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_QUERY;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.SELECTOR_PARENT;
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_SET_CONTENT;
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CONTEXT_BASETYPE_ID;
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CONTEXT_TRANSACTION;
@@ -143,12 +145,15 @@ public class CmisBrowserBindingServlet e
             rootDispatcher.addResource(SELECTOR_CHILDREN, METHOD_GET, NavigationService.class,
"getChildren");
             rootDispatcher.addResource(SELECTOR_DESCENDANTS, METHOD_GET, NavigationService.class,
"getDescendants");
             rootDispatcher.addResource(SELECTOR_FOLDER_TREE, METHOD_GET, NavigationService.class,
"getFolderTree");
+            rootDispatcher.addResource(SELECTOR_PARENT, METHOD_GET, NavigationService.class,
"getFolderParent");
             rootDispatcher.addResource(SELECTOR_PARENTS, METHOD_GET, NavigationService.class,
"getObjectParents");
             rootDispatcher.addResource(SELECTOR_VERSIONS, METHOD_GET, VersioningService.class,
"getAllVersions");
 
             rootDispatcher.addResource(CMISACTION_CREATE_DOCUMENT, METHOD_POST, ObjectService.class,
"createDocument");
             rootDispatcher.addResource(CMISACTION_CREATE_FOLDER, METHOD_POST, ObjectService.class,
"createFolder");
             rootDispatcher.addResource(CMISACTION_SET_CONTENT, METHOD_POST, ObjectService.class,
"setContentStream");
+            rootDispatcher.addResource(CMISACTION_DELETE_CONTENT, METHOD_POST, ObjectService.class,
+                    "deleteContentStream");
             rootDispatcher.addResource(CMISACTION_DELETE, METHOD_POST, ObjectService.class,
"deleteObject");
             rootDispatcher.addResource(CMISACTION_DELETE_TREE, METHOD_POST, ObjectService.class,
"deleteTree");
         } catch (NoSuchMethodException e) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/NavigationService.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/NavigationService.java?rev=1198956&r1=1198955&r2=1198956&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/NavigationService.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/NavigationService.java
Mon Nov  7 21:44:30 2011
@@ -18,7 +18,16 @@
  */
 package org.apache.chemistry.opencmis.server.impl.browser;
 
-import static org.apache.chemistry.opencmis.commons.impl.Constants.*;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_ALLOWABLE_ACTIONS;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_DEPTH;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_FILTER;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_MAX_ITEMS;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_ORDER_BY;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_PATH_SEGMENT;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_RELATIONSHIPS;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_RELATIVE_PATH_SEGMENT;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_RENDITION_FILTER;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_SKIP_COUNT;
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CONTEXT_OBJECT_ID;
 import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBigIntegerParameter;
 import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBooleanParameter;
@@ -31,12 +40,12 @@ 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.data.ObjectInFolderContainer;
 import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
 import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
-import org.apache.chemistry.opencmis.commons.impl.Constants;
 import org.apache.chemistry.opencmis.commons.server.CallContext;
 import org.apache.chemistry.opencmis.commons.server.CmisService;
 import org.apache.chemistry.opencmis.server.impl.browser.json.JSONConverter;
@@ -153,6 +162,29 @@ public final class NavigationService {
     }
 
     /**
+     * getFolderParent.
+     */
+    public static void getFolderParent(CallContext context, CmisService service, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        // get parameters
+        String objectId = (String) context.get(CONTEXT_OBJECT_ID);
+        String filter = getStringParameter(request, PARAM_FILTER);
+
+        // execute
+        ObjectData parent = service.getFolderParent(repositoryId, objectId, filter, null);
+
+        if (parent == null) {
+            throw new CmisRuntimeException("Parent is null!");
+        }
+
+        TypeCache typeCache = new TypeCache(repositoryId, service);
+        JSONObject jsonObject = JSONConverter.convert(parent, typeCache);
+
+        response.setStatus(HttpServletResponse.SC_OK);
+        BrowserBindingUtils.writeJSON(jsonObject, request, response);
+    }
+
+    /**
      * getObjectParents.
      */
     @SuppressWarnings("unchecked")

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.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/ObjectService.java?rev=1198956&r1=1198955&r2=1198956&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java
Mon Nov  7 21:44:30 2011
@@ -18,8 +18,29 @@
  */
 package org.apache.chemistry.opencmis.server.impl.browser;
 
-import static org.apache.chemistry.opencmis.commons.impl.Constants.*;
-import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.*;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.MEDIATYPE_OCTETSTREAM;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_ACL;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_ALLOWABLE_ACTIONS;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_FILTER;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_POLICY_IDS;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_RELATIONSHIPS;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_RENDITION_FILTER;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_RETURN_VERSION;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_STREAM_ID;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_VERSIONIG_STATE;
+import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_CONTENT;
+import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileBaseUrl;
+import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileUrl;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CONTEXT_OBJECT_ID;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.PARAM_TRANSACTION;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createAddAcl;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createContentStream;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createCookieValue;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createPolicies;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createProperties;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createRemoveAcl;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.setCookie;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.writeJSON;
 import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBooleanParameter;
 import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getEnumParameter;
 import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
@@ -34,10 +55,13 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.data.FailedToDeleteData;
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.chemistry.opencmis.commons.impl.Constants;
 import org.apache.chemistry.opencmis.commons.impl.ReturnVersion;
 import org.apache.chemistry.opencmis.commons.server.CallContext;
 import org.apache.chemistry.opencmis.commons.server.CmisService;
@@ -60,18 +84,15 @@ public final class ObjectService {
             HttpServletRequest request, HttpServletResponse response) throws Exception {
         // get parameters
         String folderId = (String) context.get(CONTEXT_OBJECT_ID);
-        VersioningState versioningState = getEnumParameter(request, PARAM_VERSIONIG_STATE,
-                VersioningState.class);
+        VersioningState versioningState = getEnumParameter(request, PARAM_VERSIONIG_STATE,
VersioningState.class);
         String transaction = getStringParameter(request, PARAM_TRANSACTION);
 
         ControlParser cp = new ControlParser(request);
 
         TypeCache typeCache = new TypeCache(repositoryId, service);
 
-        String newObjectId = service.createDocument(repositoryId,
-                createProperties(cp, null, typeCache), folderId,
-                createContentStream(request), versioningState,
-                createPolicies(cp), createAddAcl(cp),
+        String newObjectId = service.createDocument(repositoryId, createProperties(cp, null,
typeCache), folderId,
+                createContentStream(request), versioningState, createPolicies(cp), createAddAcl(cp),
                 createRemoveAcl(cp), null);
 
         ObjectInfo objectInfo = service.getObjectInfo(repositoryId, newObjectId);
@@ -103,10 +124,8 @@ public final class ObjectService {
 
         TypeCache typeCache = new TypeCache(repositoryId, service);
 
-        String newObjectId = service.createFolder(repositoryId,
-                createProperties(cp, null, typeCache), folderId,
-                createPolicies(cp), createAddAcl(cp),
-                createRemoveAcl(cp), null);
+        String newObjectId = service.createFolder(repositoryId, createProperties(cp, null,
typeCache), folderId,
+                createPolicies(cp), createAddAcl(cp), createRemoveAcl(cp), null);
 
         ObjectInfo objectInfo = service.getObjectInfo(repositoryId, newObjectId);
         if (objectInfo == null) {
@@ -210,9 +229,9 @@ public final class ObjectService {
             HttpServletRequest request, HttpServletResponse response) throws Exception {
         // get parameters
         String objectId = (String) context.get(CONTEXT_OBJECT_ID);
-        // TODO: more parameters
+        Boolean allVersions = getBooleanParameter(request, Constants.PARAM_ALL_VERSIONS);
 
-        service.deleteObject(repositoryId, objectId, null, null);
+        service.deleteObject(repositoryId, objectId, allVersions, null);
 
         response.setStatus(HttpServletResponse.SC_NO_CONTENT);
     }
@@ -221,24 +240,87 @@ public final class ObjectService {
             HttpServletRequest request, HttpServletResponse response) throws Exception {
         // get parameters
         String objectId = (String) context.get(CONTEXT_OBJECT_ID);
-        // TODO: more parameters
+        Boolean allVersions = getBooleanParameter(request, Constants.PARAM_ALL_VERSIONS);
+        UnfileObject unfileObjects = getEnumParameter(request, Constants.PARAM_UNFILE_OBJECTS,
UnfileObject.class);
+        Boolean continueOnFailure = getBooleanParameter(request, Constants.PARAM_CONTINUE_ON_FAILURE);
 
-        service.deleteTree(repositoryId, objectId, null, null, null, null);
+        // execute
+        FailedToDeleteData ftd = service.deleteTree(repositoryId, objectId, allVersions,
unfileObjects,
+                continueOnFailure, null);
+
+        if ((ftd != null) && (ftd.getIds() != null) && (ftd.getIds().size()
> 0)) {
+            // TODO
+        }
 
         response.setStatus(HttpServletResponse.SC_NO_CONTENT);
     }
 
-    // TODO: doesn't work
-    public static void setContentStream(CallContext context, CmisService service, String
repositoryId,
+    /**
+     * Delete content stream.
+     */
+    public static void deleteContentStream(CallContext context, CmisService service, String
repositoryId,
             HttpServletRequest request, HttpServletResponse response) throws Exception {
         // get parameters
         String objectId = (String) context.get(CONTEXT_OBJECT_ID);
+        String changeToken = getStringParameter(request, Constants.PARAM_CHANGE_TOKEN);
 
         // execute
-        service.setContentStream(repositoryId, new Holder<String>(objectId),
-                true, null, createContentStream(request), null);
+        Holder<String> objectIdHolder = new Holder<String>(objectId);
+        Holder<String> changeTokenHolder = (changeToken == null ? null : new Holder<String>(changeToken));
+        service.deleteContentStream(repositoryId, objectIdHolder, changeTokenHolder, null);
+
+        // set headers
+        String newObjectId = (objectIdHolder.getValue() == null ? objectId : objectIdHolder.getValue());
+
+        response.setStatus(HttpServletResponse.SC_OK);
+
+        ObjectData object = service.getObject(repositoryId, newObjectId, null, false, IncludeRelationships.NONE,
+                "cmis:none", false, false, null);
 
-        getObject(context, service, repositoryId, request, response);
+        if (object == null) {
+            throw new CmisRuntimeException("Object is null!");
+        }
+
+        TypeCache typeCache = new TypeCache(repositoryId, service);
+        JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+
+        writeJSON(jsonObject, request, response);
     }
 
+    /**
+     * Set content stream.
+     */
+    public static void setContentStream(CallContext context, CmisService service, String
repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        // get parameters
+        String objectId = (String) context.get(CONTEXT_OBJECT_ID);
+        String changeToken = getStringParameter(request, Constants.PARAM_CHANGE_TOKEN);
+        Boolean overwriteFlag = getBooleanParameter(request, Constants.PARAM_OVERWRITE_FLAG);
+
+        // execute
+        Holder<String> objectIdHolder = new Holder<String>(objectId);
+        Holder<String> changeTokenHolder = (changeToken == null ? null : new Holder<String>(changeToken));
+        service.setContentStream(repositoryId, objectIdHolder, overwriteFlag, changeTokenHolder,
+                createContentStream(request), null);
+
+        String newObjectId = (objectIdHolder.getValue() == null ? objectId : objectIdHolder.getValue());
+
+        // set headers
+        String location = compileUrl(compileBaseUrl(request, repositoryId), RESOURCE_CONTENT,
newObjectId);
+
+        response.setStatus(HttpServletResponse.SC_CREATED);
+        response.setHeader("Location", location);
+
+        ObjectData object = service.getObject(repositoryId, newObjectId, null, false, IncludeRelationships.NONE,
+                "cmis:none", false, false, null);
+
+        if (object == null) {
+            throw new CmisRuntimeException("Object is null!");
+        }
+
+        TypeCache typeCache = new TypeCache(repositoryId, service);
+        JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+
+        writeJSON(jsonObject, request, response);
+    }
 }



Mime
View raw message