You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2011/11/09 01:39:21 UTC
svn commit: r1199570 - in /chemistry/opencmis/trunk:
chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/
chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apa...
Author: fmui
Date: Wed Nov 9 00:39:21 2011
New Revision: 1199570
URL: http://svn.apache.org/viewvc?rev=1199570&view=rev
Log:
more browser binding code
Added:
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/MultiFilingService.java (with props)
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java
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/ObjectService.java
Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java?rev=1199570&r1=1199569&r2=1199570&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java Wed Nov 9 00:39:21 2011
@@ -139,6 +139,7 @@ public final class Constants {
public static final String PARAM_Q = "q";
public static final String PARAM_SEARCH_ALL_VERSIONS = "searchAllVersions";
public static final String PARAM_ACL_PROPAGATION = "ACLPropagation";
+ public static final String PARAM_SOURCE_ID = "sourceId";
// rendition filter
public static final String RENDITION_NONE = "cmis:none";
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=1199570&r1=1199569&r2=1199570&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 Wed Nov 9 00:39:21 2011
@@ -93,6 +93,7 @@ public class BrowserBindingUtils {
public static final String SELECTOR_CHECKEDOUT = "checkedout";
public static final String CMISACTION_CREATE_DOCUMENT = "createDocument";
+ public static final String CMISACTION_CREATE_DOCUMENT_FROM_SOURCE = "createDocumentFromSource";
public static final String CMISACTION_CREATE_FOLDER = "createFolder";
public static final String CMISACTION_CREATE_RELATIONSHIP = "createRelationship";
public static final String CMISACTION_CREATE_POLICY = "createPolicy";
@@ -101,6 +102,8 @@ public class BrowserBindingUtils {
public static final String CMISACTION_DELETE = "delete";
public static final String CMISACTION_DELETE_TREE = "deleteTree";
public static final String CMISACTION_MOVE = "move";
+ public static final String CMISACTION_ADD_OBJECT_TO_FOLDER = "addObjectToFolder";
+ public static final String CMISACTION_REMOVE_OBJECT_FROM_FOLDER = "removeObjectFromFolder";
public static final String CMISACTION_QUERY = "query";
public static final String CMISACTION_CHECK_OUT = "checkOut";
public static final String CMISACTION_CANCEL_CHECK_OUT = "cancelCheckOut";
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=1199570&r1=1199569&r2=1199570&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 Wed Nov 9 00:39:21 2011
@@ -19,10 +19,12 @@
package org.apache.chemistry.opencmis.server.impl.browser;
import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_OBJECT_ID;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_ADD_OBJECT_TO_FOLDER;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_CANCEL_CHECK_OUT;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_CHECK_IN;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_CHECK_OUT;
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_DOCUMENT_FROM_SOURCE;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_CREATE_FOLDER;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_CREATE_POLICY;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_CREATE_RELATIONSHIP;
@@ -31,6 +33,7 @@ import static org.apache.chemistry.openc
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_DELETE_TREE;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_MOVE;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_QUERY;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_REMOVE_OBJECT_FROM_FOLDER;
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;
@@ -151,6 +154,8 @@ public class CmisBrowserBindingServlet e
repositoryDispatcher.addResource(CMISACTION_QUERY, METHOD_POST, DiscoveryService.class, "query");
repositoryDispatcher.addResource(CMISACTION_CREATE_DOCUMENT, METHOD_POST, ObjectService.class,
"createDocument");
+ repositoryDispatcher.addResource(CMISACTION_CREATE_DOCUMENT_FROM_SOURCE, METHOD_POST, ObjectService.class,
+ "createDocumentFromSource");
repositoryDispatcher
.addResource(CMISACTION_CREATE_POLICY, METHOD_POST, ObjectService.class, "createPolicy");
repositoryDispatcher.addResource(CMISACTION_CREATE_RELATIONSHIP, METHOD_POST, ObjectService.class,
@@ -173,6 +178,8 @@ public class CmisBrowserBindingServlet e
rootDispatcher.addResource(SELECTOR_CHECKEDOUT, METHOD_GET, DiscoveryService.class, "getCheckedOutDocs");
rootDispatcher.addResource(CMISACTION_CREATE_DOCUMENT, METHOD_POST, ObjectService.class, "createDocument");
+ rootDispatcher.addResource(CMISACTION_CREATE_DOCUMENT_FROM_SOURCE, METHOD_POST, ObjectService.class,
+ "createDocumentFromSource");
rootDispatcher.addResource(CMISACTION_CREATE_FOLDER, METHOD_POST, ObjectService.class, "createFolder");
rootDispatcher.addResource(CMISACTION_CREATE_POLICY, METHOD_POST, ObjectService.class, "createPolicy");
rootDispatcher.addResource(CMISACTION_SET_CONTENT, METHOD_POST, ObjectService.class, "setContentStream");
@@ -181,6 +188,10 @@ public class CmisBrowserBindingServlet e
rootDispatcher.addResource(CMISACTION_DELETE, METHOD_POST, ObjectService.class, "deleteObject");
rootDispatcher.addResource(CMISACTION_DELETE_TREE, METHOD_POST, ObjectService.class, "deleteTree");
rootDispatcher.addResource(CMISACTION_MOVE, METHOD_POST, ObjectService.class, "moveObject");
+ rootDispatcher.addResource(CMISACTION_ADD_OBJECT_TO_FOLDER, METHOD_POST, MultiFilingService.class,
+ "addObjectToFolder");
+ rootDispatcher.addResource(CMISACTION_REMOVE_OBJECT_FROM_FOLDER, METHOD_POST, MultiFilingService.class,
+ "removeObjectFromFolder");
rootDispatcher.addResource(CMISACTION_CHECK_OUT, METHOD_POST, VersioningService.class, "checkOut");
rootDispatcher.addResource(CMISACTION_CANCEL_CHECK_OUT, METHOD_POST, VersioningService.class,
"cancelCheckOut");
Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/MultiFilingService.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/MultiFilingService.java?rev=1199570&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/MultiFilingService.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/MultiFilingService.java Wed Nov 9 00:39:21 2011
@@ -0,0 +1,114 @@
+/*
+ * 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.commons.impl.Constants.PARAM_FOLDER_ID;
+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.getSimpleObject;
+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.getStringParameter;
+
+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.commons.spi.Holder;
+import org.apache.chemistry.opencmis.server.impl.browser.json.JSONConverter;
+import org.json.simple.JSONObject;
+
+/**
+ * MultiFiling Service operations.
+ */
+public class MultiFilingService {
+
+ /*
+ * addObjectToFolder.
+ */
+ public static void addObjectToFolder(CallContext context, CmisService service, String repositoryId,
+ HttpServletRequest request, HttpServletResponse response) throws Exception {
+ // get parameters
+ String objectId = (String) context.get(CONTEXT_OBJECT_ID);
+ String folderId = getStringParameter(request, PARAM_FOLDER_ID);
+ Boolean allVersions = getBooleanParameter(request, Constants.PARAM_ALL_VERSIONS);
+
+ // execute
+ Holder<String> objectIdHolder = new Holder<String>(objectId);
+ service.addObjectToFolder(repositoryId, objectId, folderId, allVersions, null);
+
+ String newObjectId = (objectIdHolder.getValue() == null ? objectId : objectIdHolder.getValue());
+
+ ObjectData object = getSimpleObject(service, repositoryId, newObjectId);
+ if (object == null) {
+ throw new CmisRuntimeException("Object is null!");
+ }
+
+ // set headers
+ String location = compileUrl(compileBaseUrl(request, repositoryId), RESOURCE_CONTENT, newObjectId);
+
+ response.setStatus(HttpServletResponse.SC_CREATED);
+ response.setHeader("Location", location);
+
+ // return object
+ TypeCache typeCache = new TypeCache(repositoryId, service);
+ JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+
+ writeJSON(jsonObject, request, response);
+ }
+
+ /*
+ * removeObjectFromFolder.
+ */
+ public static void removeObjectFromFolder(CallContext context, CmisService service, String repositoryId,
+ HttpServletRequest request, HttpServletResponse response) throws Exception {
+ // get parameters
+ String objectId = (String) context.get(CONTEXT_OBJECT_ID);
+ String folderId = getStringParameter(request, PARAM_FOLDER_ID);
+
+ // execute
+ Holder<String> objectIdHolder = new Holder<String>(objectId);
+ service.removeObjectFromFolder(repositoryId, objectId, folderId, null);
+
+ String newObjectId = (objectIdHolder.getValue() == null ? objectId : objectIdHolder.getValue());
+
+ ObjectData object = getSimpleObject(service, repositoryId, newObjectId);
+ if (object == null) {
+ throw new CmisRuntimeException("Object is null!");
+ }
+
+ // set headers
+ String location = compileUrl(compileBaseUrl(request, repositoryId), RESOURCE_CONTENT, newObjectId);
+
+ response.setStatus(HttpServletResponse.SC_CREATED);
+ response.setHeader("Location", location);
+
+ // return object
+ TypeCache typeCache = new TypeCache(repositoryId, service);
+ JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+
+ writeJSON(jsonObject, request, response);
+ }
+}
Propchange: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/MultiFilingService.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1199570&r1=1199569&r2=1199570&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 Wed Nov 9 00:39:21 2011
@@ -27,6 +27,7 @@ import static org.apache.chemistry.openc
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_SOURCE_FOLDER_ID;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_SOURCE_ID;
import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_STREAM_ID;
import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_TARGET_FOLDER_ID;
import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_VERSIONIG_STATE;
@@ -123,6 +124,40 @@ public final class ObjectService {
}
/**
+ * Create document from source.
+ */
+ public static void createDocumentFromSource(CallContext context, CmisService service, String repositoryId,
+ HttpServletRequest request, HttpServletResponse response) throws Exception {
+ // get parameters
+ String folderId = (String) context.get(CONTEXT_OBJECT_ID);
+ String sourceId = getStringParameter(request, PARAM_SOURCE_ID);
+ VersioningState versioningState = getEnumParameter(request, PARAM_VERSIONIG_STATE, VersioningState.class);
+ String transaction = getStringParameter(request, PARAM_TRANSACTION);
+
+ // execute
+ ControlParser cp = new ControlParser(request);
+ TypeCache typeCache = new TypeCache(repositoryId, service);
+
+ String newObjectId = service.createDocumentFromSource(repositoryId, sourceId,
+ createProperties(cp, null, typeCache), folderId, versioningState, createPolicies(cp), createAddAcl(cp),
+ createRemoveAcl(cp), null);
+
+ ObjectData object = getSimpleObject(service, repositoryId, newObjectId);
+ if (object == null) {
+ throw new CmisRuntimeException("New document is null!");
+ }
+
+ // return object
+ JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+
+ response.setStatus(HttpServletResponse.SC_CREATED);
+ setCookie(request, response, repositoryId, transaction,
+ createCookieValue(HttpServletResponse.SC_CREATED, object.getId(), null, null));
+
+ writeJSON(jsonObject, request, response);
+ }
+
+ /**
* Create folder.
*/
public static void createFolder(CallContext context, CmisService service, String repositoryId,