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 2012/01/25 08:58:27 UTC
svn commit: r1235671 [1/3] - in /chemistry/opencmis/trunk:
chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/
chemistry-opencmis-client/chemistry-opencmis-client-binding...
Author: fmui
Date: Wed Jan 25 07:58:25 2012
New Revision: 1235671
URL: http://svn.apache.org/viewvc?rev=1235671&view=rev
Log:
- more browser binding code
- enabled FIT for browser binding
Added:
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/BrowserSimpleBindingIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/browser/
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/browser/ReadOnlyAclCapabilityBrowserIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/browser/ReadOnlyContentStreamBrowserIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/browser/ReadOnlyDiscoverBrowserIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/browser/ReadOnlyNavigationBrowserIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/browser/ReadOnlyObjectBrowserIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/browser/ReadOnlyRepositoryInfoBrowserIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/browser/ReadOnlySessionBrowserIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/browser/ReadOnlyTypeBrowserIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/browser/TransientObjectBrowserIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/browser/WriteAclBrowserIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/browser/WriteObjectBrowserIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/browser/WriteObjectCopyBrowserIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/browser/WriteObjectMoveBrowserIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/browser/WriteObjectRelationBrowserIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/browser/WriteObjectVersionBrowserIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/extensions/BrowserSampleIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/misc/ReadOnlyCreateSessionBrowserIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/sample/BrowserSampleIT.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/resources/inmemory.browser.properties (with props)
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AbstractBrowserBindingService.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AclServiceImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/DiscoveryServiceImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/FormDataWriter.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/MultiFilingServiceImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/PolicyServiceImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RelationshipServiceImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/VersioningServiceImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/HttpUtils.java
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-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConstants.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.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/DiscoveryService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/MultiFilingService.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
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/PolicyService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RelationshipService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/VersioningService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/createdocument.html
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/createfolder.html
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/demo.html
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/web/index.html
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/SessionFactory.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AbstractBindingIT.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AbstractSimpleBindingIT.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AtomPubSimpleBindingIT.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/WebServicesSimpleBindingIT.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/Fixture.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/sample/AtomPubSampleIT.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/sample/WebServicesSampleIT.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/resources/inmemory.atom.properties
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/resources/inmemory.ws.properties
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteRelationshipTest.java
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AbstractBrowserBindingService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AbstractBrowserBindingService.java?rev=1235671&r1=1235670&r2=1235671&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AbstractBrowserBindingService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AbstractBrowserBindingService.java Wed Jan 25 07:58:25 2012
@@ -183,7 +183,6 @@ public abstract class AbstractBrowserBin
* Converts an error message or a HTTP status code into an Exception.
*/
protected CmisBaseException convertStatusCode(int code, String message, String errorContent, Throwable t) {
-
Object obj = null;
try {
JSONParser parser = new JSONParser();
@@ -345,6 +344,28 @@ public abstract class AbstractBrowserBin
return resp;
}
+ /**
+ * Performs a POST on an URL, checks the response code and returns the
+ * result.
+ */
+ protected void postAndConsume(UrlBuilder url, String contentType, HttpUtils.Output writer) {
+ HttpUtils.Response resp = post(url, contentType, writer);
+
+ InputStream stream = resp.getStream();
+ try {
+ byte[] buffer = new byte[4096];
+ while (stream.read(buffer) > -1) {
+ }
+ } catch (Exception e) {
+ // ignore
+ } finally {
+ try {
+ stream.close();
+ } catch (Exception e) {
+ }
+ }
+ }
+
// ---- URL ----
/**
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AclServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AclServiceImpl.java?rev=1235671&r1=1235670&r2=1235671&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AclServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AclServiceImpl.java Wed Jan 25 07:58:25 2012
@@ -18,6 +18,7 @@
*/
package org.apache.chemistry.opencmis.client.bindings.spi.browser;
+import java.io.OutputStream;
import java.util.Map;
import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
@@ -41,7 +42,7 @@ public class AclServiceImpl extends Abst
public AclServiceImpl(BindingSession session) {
setSession(session);
}
-
+
public Acl getAcl(String repositoryId, String objectId, Boolean onlyBasicPermissions, ExtensionsData extension) {
// build URL
UrlBuilder url = getObjectUrl(repositoryId, objectId, Constants.SELECTOR_ACL);
@@ -56,8 +57,23 @@ public class AclServiceImpl extends Abst
public Acl applyAcl(String repositoryId, String objectId, Acl addAces, Acl removeAces,
AclPropagation aclPropagation, ExtensionsData extension) {
- // TODO Auto-generated method stub
- return null;
- }
+ // build URL
+ UrlBuilder url = getObjectUrl(repositoryId, objectId);
+ // prepare form data
+ final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_APPLY_ACL);
+ formData.addAddAcesParameters(addAces);
+ formData.addRemoveAcesParameters(removeAces);
+ formData.addParameter(Constants.PARAM_ACL_PROPAGATION, aclPropagation);
+
+ // send and parse
+ HttpUtils.Response resp = post(url, formData.getContentType(), new HttpUtils.Output() {
+ public void write(OutputStream out) throws Exception {
+ formData.write(out);
+ }
+ });
+ Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
+
+ return JSONConverter.convertAcl(json, null);
+ }
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/DiscoveryServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/DiscoveryServiceImpl.java?rev=1235671&r1=1235670&r2=1235671&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/DiscoveryServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/DiscoveryServiceImpl.java Wed Jan 25 07:58:25 2012
@@ -18,12 +18,19 @@
*/
package org.apache.chemistry.opencmis.client.bindings.spi.browser;
+import java.io.OutputStream;
import java.math.BigInteger;
+import java.util.Map;
import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+import org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils;
import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
import org.apache.chemistry.opencmis.commons.data.ObjectList;
import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.impl.Constants;
+import org.apache.chemistry.opencmis.commons.impl.JSONConstants;
+import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
+import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
import org.apache.chemistry.opencmis.commons.spi.DiscoveryService;
import org.apache.chemistry.opencmis.commons.spi.Holder;
@@ -42,14 +49,53 @@ public class DiscoveryServiceImpl extend
public ObjectList query(String repositoryId, String statement, Boolean searchAllVersions,
Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
- // TODO Auto-generated method stub
- return null;
+ // build URL
+ UrlBuilder url = getRepositoryUrl(repositoryId);
+
+ // prepare form data
+ final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_QUERY);
+ formData.addParameter(Constants.PARAM_Q, statement);
+ formData.addParameter(Constants.PARAM_SEARCH_ALL_VERSIONS, searchAllVersions);
+ formData.addParameter(Constants.PARAM_ALLOWABLE_ACTIONS, includeAllowableActions);
+ formData.addParameter(Constants.PARAM_RELATIONSHIPS, includeRelationships);
+ formData.addParameter(Constants.PARAM_RENDITION_FILTER, renditionFilter);
+ formData.addParameter(Constants.PARAM_MAX_ITEMS, maxItems);
+ formData.addParameter(Constants.PARAM_SKIP_COUNT, skipCount);
+
+ // send and parse
+ HttpUtils.Response resp = post(url, formData.getContentType(), new HttpUtils.Output() {
+ public void write(OutputStream out) throws Exception {
+ formData.write(out);
+ }
+ });
+
+ Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
+ return JSONConverter.convertObjectList(json);
}
public ObjectList getContentChanges(String repositoryId, Holder<String> changeLogToken, Boolean includeProperties,
String filter, Boolean includePolicyIds, Boolean includeAcl, BigInteger maxItems, ExtensionsData extension) {
- // TODO Auto-generated method stub
- return null;
- }
+ // build URL
+ UrlBuilder url = getRepositoryUrl(repositoryId, Constants.SELECTOR_CONTENT_CHANGES);
+ url.addParameter(Constants.PARAM_SUB_RELATIONSHIP_TYPES,
+ changeLogToken == null ? null : changeLogToken.getValue());
+ url.addParameter(Constants.PARAM_PROPERTIES, includeProperties);
+ url.addParameter(Constants.PARAM_FILTER, filter);
+ url.addParameter(Constants.PARAM_POLICY_IDS, includePolicyIds);
+ url.addParameter(Constants.PARAM_ACL, includeAcl);
+ url.addParameter(Constants.PARAM_MAX_ITEMS, maxItems);
+
+ // read and parse
+ HttpUtils.Response resp = read(url);
+ Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
+
+ if (changeLogToken != null && json != null) {
+ Object token = json.get(JSONConstants.JSON_OBJECTLIST_CHANGE_LOG_TOKEN);
+ if (token instanceof String) {
+ changeLogToken.setValue((String) token);
+ }
+ }
+ return JSONConverter.convertObjectList(json);
+ }
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/FormDataWriter.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/FormDataWriter.java?rev=1235671&r1=1235670&r2=1235671&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/FormDataWriter.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/FormDataWriter.java Wed Jan 25 07:58:25 2012
@@ -44,8 +44,7 @@ public class FormDataWriter {
private static final String CRLF = "\r\n";
private static final int BUFFER_SIZE = 64 * 1024;
- private final String boundary = "opencmis" + Long.toHexString(System.currentTimeMillis())
- + Long.toHexString(this.hashCode());
+ private final String boundary;
private final Map<String, String> parameters = new LinkedHashMap<String, String>();
private ContentStream contentStream;
@@ -56,6 +55,8 @@ public class FormDataWriter {
public FormDataWriter(String action, ContentStream contentStream) {
addParameter(Constants.CONTROL_CMISACTION, action);
this.contentStream = contentStream;
+ boundary = "aPacHeCheMIStryoPEncmiS" + Long.toHexString(action.hashCode()) + action
+ + Long.toHexString(System.currentTimeMillis()) + Long.toHexString(this.hashCode());
}
public void addParameter(String name, Object value) {
@@ -191,7 +192,8 @@ public class FormDataWriter {
}
String mediaType = contentStream.getMimeType();
- if (mediaType == null || mediaType.length() == 0) {
+ if (mediaType == null || mediaType.indexOf('/') < 1 || mediaType.indexOf('\n') > -1
+ || mediaType.indexOf('\r') > -1) {
mediaType = Constants.MEDIATYPE_OCTETSTREAM;
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/MultiFilingServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/MultiFilingServiceImpl.java?rev=1235671&r1=1235670&r2=1235671&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/MultiFilingServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/MultiFilingServiceImpl.java Wed Jan 25 07:58:25 2012
@@ -18,8 +18,13 @@
*/
package org.apache.chemistry.opencmis.client.bindings.spi.browser;
+import java.io.OutputStream;
+
import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+import org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils;
import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
+import org.apache.chemistry.opencmis.commons.impl.Constants;
+import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
import org.apache.chemistry.opencmis.commons.spi.MultiFilingService;
/**
@@ -33,16 +38,38 @@ public class MultiFilingServiceImpl exte
public MultiFilingServiceImpl(BindingSession session) {
setSession(session);
}
-
+
public void addObjectToFolder(String repositoryId, String objectId, String folderId, Boolean allVersions,
ExtensionsData extension) {
- // TODO Auto-generated method stub
+ // build URL
+ UrlBuilder url = getObjectUrl(repositoryId, objectId);
+ // prepare form data
+ final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_ADD_OBJECT_TO_FOLDER);
+ formData.addParameter(Constants.PARAM_FOLDER_ID, folderId);
+ formData.addParameter(Constants.PARAM_ALL_VERSIONS, allVersions);
+
+ // send and parse
+ postAndConsume(url, formData.getContentType(), new HttpUtils.Output() {
+ public void write(OutputStream out) throws Exception {
+ formData.write(out);
+ }
+ });
}
public void removeObjectFromFolder(String repositoryId, String objectId, String folderId, ExtensionsData extension) {
- // TODO Auto-generated method stub
+ // build URL
+ UrlBuilder url = getObjectUrl(repositoryId, objectId);
+ // prepare form data
+ final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_REMOVE_OBJECT_FROM_FOLDER);
+ formData.addParameter(Constants.PARAM_FOLDER_ID, folderId);
+
+ // send and parse
+ postAndConsume(url, formData.getContentType(), new HttpUtils.Output() {
+ public void write(OutputStream out) throws Exception {
+ formData.write(out);
+ }
+ });
}
-
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.java?rev=1235671&r1=1235670&r2=1235671&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.java Wed Jan 25 07:58:25 2012
@@ -25,6 +25,7 @@ import java.util.Map;
import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
import org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.data.Acl;
import org.apache.chemistry.opencmis.commons.data.AllowableActions;
import org.apache.chemistry.opencmis.commons.data.ContentStream;
@@ -36,10 +37,12 @@ import org.apache.chemistry.opencmis.com
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.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.impl.Constants;
import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
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.FailedToDeleteDataImpl;
import org.apache.chemistry.opencmis.commons.spi.Holder;
import org.apache.chemistry.opencmis.commons.spi.ObjectService;
@@ -287,14 +290,63 @@ public class ObjectServiceImpl extends A
public void updateProperties(String repositoryId, Holder<String> objectId, Holder<String> changeToken,
Properties properties, ExtensionsData extension) {
- // TODO Auto-generated method stub
+ // we need an object id
+ if ((objectId == null) || (objectId.getValue() == null) || (objectId.getValue().length() == 0)) {
+ throw new CmisInvalidArgumentException("Object id must be set!");
+ }
+
+ // build URL
+ UrlBuilder url = getObjectUrl(repositoryId, objectId.getValue());
+
+ // prepare form data
+ final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_UPDATE_PROPERTIES);
+ formData.addPropertiesParameters(properties);
+ formData.addParameter(Constants.PARAM_CHANGE_TOKEN, (changeToken == null ? null : changeToken.getValue()));
+ // send and parse
+ HttpUtils.Response resp = post(url, formData.getContentType(), new HttpUtils.Output() {
+ public void write(OutputStream out) throws Exception {
+ formData.write(out);
+ }
+ });
+
+ Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
+ ObjectData newObj = JSONConverter.convertObject(json);
+
+ objectId.setValue(newObj == null ? null : newObj.getId());
+
+ if (changeToken != null && newObj.getProperties() != null) {
+ Object ct = newObj.getProperties().getProperties().get(PropertyIds.CHANGE_TOKEN);
+ changeToken.setValue(ct == null ? null : ct.toString());
+ }
}
public void moveObject(String repositoryId, Holder<String> objectId, String targetFolderId, String sourceFolderId,
ExtensionsData extension) {
- // TODO Auto-generated method stub
+ // we need an object id
+ if ((objectId == null) || (objectId.getValue() == null) || (objectId.getValue().length() == 0)) {
+ throw new CmisInvalidArgumentException("Object id must be set!");
+ }
+
+ // build URL
+ UrlBuilder url = getObjectUrl(repositoryId, objectId.getValue());
+ // prepare form data
+ final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_MOVE);
+ formData.addParameter(Constants.PARAM_TARGET_FOLDER_ID, targetFolderId);
+ formData.addParameter(Constants.PARAM_SOURCE_FOLDER_ID, sourceFolderId);
+
+ // send and parse
+ HttpUtils.Response resp = post(url, formData.getContentType(), new HttpUtils.Output() {
+ public void write(OutputStream out) throws Exception {
+ formData.write(out);
+ }
+ });
+
+ Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
+ ObjectData newObj = JSONConverter.convertObject(json);
+
+ objectId.setValue(newObj == null ? null : newObj.getId());
}
public void deleteObject(String repositoryId, String objectId, Boolean allVersions, ExtensionsData extension) {
@@ -306,7 +358,7 @@ public class ObjectServiceImpl extends A
formData.addParameter(Constants.PARAM_ALL_VERSIONS, allVersions);
// send
- post(url, formData.getContentType(), new HttpUtils.Output() {
+ postAndConsume(url, formData.getContentType(), new HttpUtils.Output() {
public void write(OutputStream out) throws Exception {
formData.write(out);
}
@@ -315,20 +367,92 @@ public class ObjectServiceImpl extends A
public FailedToDeleteData deleteTree(String repositoryId, String folderId, Boolean allVersions,
UnfileObject unfileObjects, Boolean continueOnFailure, ExtensionsData extension) {
- // TODO Auto-generated method stub
- return null;
+ // build URL
+ UrlBuilder url = getObjectUrl(repositoryId, folderId);
+
+ // prepare form data
+ final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_DELETE_TREE);
+ formData.addParameter(Constants.PARAM_ALL_VERSIONS, allVersions);
+ formData.addParameter(Constants.PARAM_UNFILE_OBJECTS, unfileObjects);
+ formData.addParameter(Constants.PARAM_CONTINUE_ON_FAILURE, continueOnFailure);
+
+ // send
+ HttpUtils.Response resp = post(url, formData.getContentType(), new HttpUtils.Output() {
+ public void write(OutputStream out) throws Exception {
+ formData.write(out);
+ }
+ });
+
+ if (!BigInteger.ZERO.equals(resp.getContentLength())) {
+ Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
+ return JSONConverter.convertFailedToDelete(json);
+ }
+
+ return new FailedToDeleteDataImpl();
}
public void setContentStream(String repositoryId, Holder<String> objectId, Boolean overwriteFlag,
Holder<String> changeToken, ContentStream contentStream, ExtensionsData extension) {
- // TODO Auto-generated method stub
+ // we need an object id
+ if ((objectId == null) || (objectId.getValue() == null) || (objectId.getValue().length() == 0)) {
+ throw new CmisInvalidArgumentException("Object id must be set!");
+ }
+
+ // build URL
+ UrlBuilder url = getObjectUrl(repositoryId, objectId.getValue());
+
+ // prepare form data
+ final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_SET_CONTENT, contentStream);
+ formData.addParameter(Constants.PARAM_OVERWRITE_FLAG, overwriteFlag);
+ formData.addParameter(Constants.PARAM_CHANGE_TOKEN, (changeToken == null ? null : changeToken.getValue()));
+
+ // send and parse
+ HttpUtils.Response resp = post(url, formData.getContentType(), new HttpUtils.Output() {
+ public void write(OutputStream out) throws Exception {
+ formData.write(out);
+ }
+ });
+
+ Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
+ ObjectData newObj = JSONConverter.convertObject(json);
+ objectId.setValue(newObj == null ? null : newObj.getId());
+
+ if (changeToken != null && newObj.getProperties() != null) {
+ Object ct = newObj.getProperties().getProperties().get(PropertyIds.CHANGE_TOKEN);
+ changeToken.setValue(ct == null ? null : ct.toString());
+ }
}
public void deleteContentStream(String repositoryId, Holder<String> objectId, Holder<String> changeToken,
ExtensionsData extension) {
- // TODO Auto-generated method stub
+ // we need an object id
+ if ((objectId == null) || (objectId.getValue() == null) || (objectId.getValue().length() == 0)) {
+ throw new CmisInvalidArgumentException("Object id must be set!");
+ }
- }
+ // build URL
+ UrlBuilder url = getObjectUrl(repositoryId, objectId.getValue());
+
+ // prepare form data
+ final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_DELETE_CONTENT);
+ formData.addParameter(Constants.PARAM_CHANGE_TOKEN, (changeToken == null ? null : changeToken.getValue()));
+
+ // send and parse
+ HttpUtils.Response resp = post(url, formData.getContentType(), new HttpUtils.Output() {
+ public void write(OutputStream out) throws Exception {
+ formData.write(out);
+ }
+ });
+
+ Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
+ ObjectData newObj = JSONConverter.convertObject(json);
+
+ objectId.setValue(newObj == null ? null : newObj.getId());
+ if (changeToken != null && newObj.getProperties() != null) {
+ Object ct = newObj.getProperties().getProperties().get(PropertyIds.CHANGE_TOKEN);
+ changeToken.setValue(ct == null ? null : ct.toString());
+ }
+ }
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/PolicyServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/PolicyServiceImpl.java?rev=1235671&r1=1235670&r2=1235671&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/PolicyServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/PolicyServiceImpl.java Wed Jan 25 07:58:25 2012
@@ -18,11 +18,17 @@
*/
package org.apache.chemistry.opencmis.client.bindings.spi.browser;
+import java.io.OutputStream;
+import java.util.Collections;
import java.util.List;
import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+import org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils;
import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
import org.apache.chemistry.opencmis.commons.data.ObjectData;
+import org.apache.chemistry.opencmis.commons.impl.Constants;
+import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
+import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
import org.apache.chemistry.opencmis.commons.spi.PolicyService;
/**
@@ -38,19 +44,47 @@ public class PolicyServiceImpl extends A
}
public void applyPolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension) {
- // TODO Auto-generated method stub
+ // build URL
+ UrlBuilder url = getObjectUrl(repositoryId, objectId);
+ // prepare form data
+ final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_APPLY_POLICY);
+ formData.addPoliciesParameters(Collections.singletonList(policyId));
+
+ // send
+ postAndConsume(url, formData.getContentType(), new HttpUtils.Output() {
+ public void write(OutputStream out) throws Exception {
+ formData.write(out);
+ }
+ });
}
public void removePolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension) {
- // TODO Auto-generated method stub
+ // build URL
+ UrlBuilder url = getObjectUrl(repositoryId, objectId);
+ // prepare form data
+ final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_REMOVE_POLICY);
+ formData.addPoliciesParameters(Collections.singletonList(policyId));
+
+ // send
+ postAndConsume(url, formData.getContentType(), new HttpUtils.Output() {
+ public void write(OutputStream out) throws Exception {
+ formData.write(out);
+ }
+ });
}
public List<ObjectData> getAppliedPolicies(String repositoryId, String objectId, String filter,
ExtensionsData extension) {
- // TODO Auto-generated method stub
- return null;
- }
+ // build URL
+ UrlBuilder url = getObjectUrl(repositoryId, objectId, Constants.SELECTOR_POLICIES);
+ url.addParameter(Constants.PARAM_FILTER, filter);
+
+ // read and parse
+ HttpUtils.Response resp = read(url);
+ List<Object> json = parseArray(resp.getStream(), resp.getCharset());
+ return JSONConverter.convertObjects(json);
+ }
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RelationshipServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RelationshipServiceImpl.java?rev=1235671&r1=1235670&r2=1235671&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RelationshipServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RelationshipServiceImpl.java Wed Jan 25 07:58:25 2012
@@ -19,11 +19,16 @@
package org.apache.chemistry.opencmis.client.bindings.spi.browser;
import java.math.BigInteger;
+import java.util.Map;
import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+import org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils;
import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
import org.apache.chemistry.opencmis.commons.data.ObjectList;
import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
+import org.apache.chemistry.opencmis.commons.impl.Constants;
+import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
+import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
import org.apache.chemistry.opencmis.commons.spi.RelationshipService;
/**
@@ -41,8 +46,20 @@ public class RelationshipServiceImpl ext
public ObjectList getObjectRelationships(String repositoryId, String objectId, Boolean includeSubRelationshipTypes,
RelationshipDirection relationshipDirection, String typeId, String filter, Boolean includeAllowableActions,
BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
- // TODO Auto-generated method stub
- return null;
- }
+ // build URL
+ UrlBuilder url = getObjectUrl(repositoryId, objectId, Constants.SELECTOR_RELATIONSHIPS);
+ url.addParameter(Constants.PARAM_SUB_RELATIONSHIP_TYPES, includeSubRelationshipTypes);
+ url.addParameter(Constants.PARAM_RELATIONSHIP_DIRECTION, relationshipDirection);
+ url.addParameter(Constants.PARAM_TYPE_ID, typeId);
+ url.addParameter(Constants.PARAM_FILTER, filter);
+ url.addParameter(Constants.PARAM_ALLOWABLE_ACTIONS, includeAllowableActions);
+ url.addParameter(Constants.PARAM_MAX_ITEMS, maxItems);
+ url.addParameter(Constants.PARAM_SKIP_COUNT, skipCount);
+
+ // read and parse
+ HttpUtils.Response resp = read(url);
+ Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
+ return JSONConverter.convertObjectList(json);
+ }
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/VersioningServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/VersioningServiceImpl.java?rev=1235671&r1=1235670&r2=1235671&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/VersioningServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/VersioningServiceImpl.java Wed Jan 25 07:58:25 2012
@@ -18,6 +18,7 @@
*/
package org.apache.chemistry.opencmis.client.bindings.spi.browser;
+import java.io.OutputStream;
import java.util.List;
import java.util.Map;
@@ -29,6 +30,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.data.ObjectData;
import org.apache.chemistry.opencmis.commons.data.Properties;
import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.impl.Constants;
import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
import org.apache.chemistry.opencmis.commons.impl.ReturnVersion;
@@ -50,20 +52,76 @@ public class VersioningServiceImpl exten
public void checkOut(String repositoryId, Holder<String> objectId, ExtensionsData extension,
Holder<Boolean> contentCopied) {
- // TODO Auto-generated method stub
+ // we need an object id
+ if ((objectId == null) || (objectId.getValue() == null) || (objectId.getValue().length() == 0)) {
+ throw new CmisInvalidArgumentException("Object id must be set!");
+ }
+ // build URL
+ UrlBuilder url = getObjectUrl(repositoryId, objectId.getValue());
+
+ // prepare form data
+ final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_CHECK_OUT);
+
+ // send and parse
+ HttpUtils.Response resp = post(url, formData.getContentType(), new HttpUtils.Output() {
+ public void write(OutputStream out) throws Exception {
+ formData.write(out);
+ }
+ });
+
+ Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
+ ObjectData newObj = JSONConverter.convertObject(json);
+
+ objectId.setValue(newObj == null ? null : newObj.getId());
}
public void cancelCheckOut(String repositoryId, String objectId, ExtensionsData extension) {
- // TODO Auto-generated method stub
+ // build URL
+ UrlBuilder url = getObjectUrl(repositoryId, objectId);
+ // prepare form data
+ final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_CANCEL_CHECK_OUT);
+
+ // send
+ postAndConsume(url, formData.getContentType(), new HttpUtils.Output() {
+ public void write(OutputStream out) throws Exception {
+ formData.write(out);
+ }
+ });
}
public void checkIn(String repositoryId, Holder<String> objectId, Boolean major, Properties properties,
ContentStream contentStream, String checkinComment, List<String> policies, Acl addAces, Acl removeAces,
ExtensionsData extension) {
- // TODO Auto-generated method stub
+ // we need an object id
+ if ((objectId == null) || (objectId.getValue() == null) || (objectId.getValue().length() == 0)) {
+ throw new CmisInvalidArgumentException("Object id must be set!");
+ }
+
+ // build URL
+ UrlBuilder url = getObjectUrl(repositoryId, objectId.getValue());
+
+ // prepare form data
+ final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_CHECK_IN, contentStream);
+ formData.addParameter(Constants.PARAM_MAJOR, major);
+ formData.addPropertiesParameters(properties);
+ formData.addParameter(Constants.PARAM_CHECKIN_COMMENT, checkinComment);
+ formData.addPoliciesParameters(policies);
+ formData.addAddAcesParameters(addAces);
+ formData.addRemoveAcesParameters(removeAces);
+
+ // send and parse
+ HttpUtils.Response resp = post(url, formData.getContentType(), new HttpUtils.Output() {
+ public void write(OutputStream out) throws Exception {
+ formData.write(out);
+ }
+ });
+ Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
+ ObjectData newObj = JSONConverter.convertObject(json);
+
+ objectId.setValue(newObj == null ? null : newObj.getId());
}
public ObjectData getObjectOfLatestVersion(String repositoryId, String objectId, String versionSeriesId,
@@ -115,5 +173,4 @@ public class VersioningServiceImpl exten
return JSONConverter.convertObjects(json);
}
-
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/HttpUtils.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/HttpUtils.java?rev=1235671&r1=1235670&r2=1235671&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/HttpUtils.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/HttpUtils.java Wed Jan 25 07:58:25 2012
@@ -253,7 +253,8 @@ public class HttpUtils {
if (errorStream != null) {
if (contentType != null) {
String contentTypeLower = contentType.toLowerCase().split(";")[0];
- if (contentTypeLower.startsWith("text/") || contentTypeLower.endsWith("+xml")) {
+ if (contentTypeLower.startsWith("text/") || contentTypeLower.endsWith("+xml")
+ || contentTypeLower.startsWith("application/json")) {
StringBuilder sb = new StringBuilder();
try {
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=1235671&r1=1235670&r2=1235671&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 Jan 25 07:58:25 2012
@@ -123,6 +123,7 @@ public final class Constants {
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_UPDATE_PROPERTIES = "update";
public static final String CMISACTION_DELETE_CONTENT = "deleteContent";
public static final String CMISACTION_SET_CONTENT = "setContent";
public static final String CMISACTION_DELETE = "delete";
Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConstants.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/JSONConstants.java?rev=1235671&r1=1235670&r2=1235671&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConstants.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConstants.java Wed Jan 25 07:58:25 2012
@@ -262,12 +262,14 @@ public class JSONConstants {
public static final String JSON_OBJECTLIST_OBJECTS = "objects";
public static final String JSON_OBJECTLIST_HAS_MORE_ITEMS = "hasMoreItems";
public static final String JSON_OBJECTLIST_NUM_ITEMS = "numItems";
+ public static final String JSON_OBJECTLIST_CHANGE_LOG_TOKEN = "changeLogToken";
public static final Set<String> OBJECTLIST_KEYS = new HashSet<String>();
static {
OBJECTLIST_KEYS.add(JSON_OBJECTLIST_OBJECTS);
OBJECTLIST_KEYS.add(JSON_OBJECTLIST_HAS_MORE_ITEMS);
OBJECTLIST_KEYS.add(JSON_OBJECTLIST_NUM_ITEMS);
+ OBJECTLIST_KEYS.add(JSON_OBJECTLIST_CHANGE_LOG_TOKEN);
}
public static final String JSON_OBJECTINFOLDERLIST_OBJECTS = "objects";
@@ -410,6 +412,13 @@ public class JSONConstants {
TYPESCONTAINER_KEYS.add(JSON_TYPESCONTAINER_CHILDREN);
}
+ public static final String JSON_FAILEDTODELETE_ID = "ids";
+
+ public static final Set<String> FAILEDTODELETE_KEYS = new HashSet<String>();
+ static {
+ FAILEDTODELETE_KEYS.add(JSON_FAILEDTODELETE_ID);
+ }
+
// Constant utility class.
private JSONConstants() {
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.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/JSONConverter.java?rev=1235671&r1=1235670&r2=1235671&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.java Wed Jan 25 07:58:25 2012
@@ -40,6 +40,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.data.ChangeEventInfo;
import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
+import org.apache.chemistry.opencmis.commons.data.FailedToDeleteData;
import org.apache.chemistry.opencmis.commons.data.ObjectData;
import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
@@ -107,6 +108,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ChoiceImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.CmisExtensionElementImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.FailedToDeleteDataImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.FolderTypeDefinitionImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectDataImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderContainerImpl;
@@ -180,15 +182,13 @@ public class JSONConverter {
setIfNotNull(JSON_REPINFO_THIN_CLIENT_URI, repositoryInfo.getThinClientUri(), result);
setIfNotNull(JSON_REPINFO_CHANGES_INCOMPLETE, repositoryInfo.getChangesIncomplete(), result);
+ JSONArray changesOnType = new JSONArray();
if (repositoryInfo.getChangesOnType() != null) {
- JSONArray changesOnType = new JSONArray();
-
for (BaseTypeId type : repositoryInfo.getChangesOnType()) {
changesOnType.add(getJSONStringValue(type.value()));
}
-
- result.put(JSON_REPINFO_CHANGES_ON_TYPE, changesOnType);
}
+ result.put(JSON_REPINFO_CHANGES_ON_TYPE, changesOnType);
setIfNotNull(JSON_REPINFO_PRINCIPAL_ID_ANONYMOUS, repositoryInfo.getPrincipalIdAnonymous(), result);
setIfNotNull(JSON_REPINFO_PRINCIPAL_ID_ANYONE, repositoryInfo.getPrincipalIdAnyone(), result);
@@ -314,16 +314,15 @@ public class JSONConverter {
result.setChangesIncomplete(getBoolean(json, JSON_REPINFO_CHANGES_INCOMPLETE));
List<Object> changesOnType = getList(json.get(JSON_REPINFO_CHANGES_ON_TYPE));
+ List<BaseTypeId> types = new ArrayList<BaseTypeId>();
if (changesOnType != null) {
- List<BaseTypeId> types = new ArrayList<BaseTypeId>();
for (Object type : changesOnType) {
if (type != null) {
types.add(BaseTypeId.fromValue(type.toString()));
}
}
-
- result.setChangesOnType(types);
}
+ result.setChangesOnType(types);
result.setPrincipalAnonymous(getString(json, JSON_REPINFO_PRINCIPAL_ID_ANONYMOUS));
result.setPrincipalAnyone(getString(json, JSON_REPINFO_PRINCIPAL_ID_ANYONE));
@@ -825,7 +824,7 @@ public class JSONConverter {
* Converts an object.
*/
@SuppressWarnings("unchecked")
- public static JSONObject convert(ObjectData object, TypeCache typeCache) {
+ public static JSONObject convert(ObjectData object, TypeCache typeCache, boolean isQueryResult) {
if (object == null) {
return null;
}
@@ -834,7 +833,7 @@ public class JSONConverter {
// properties
if (object.getProperties() != null) {
- JSONObject properties = convert(object.getProperties(), object.getId(), typeCache);
+ JSONObject properties = convert(object.getProperties(), object.getId(), typeCache, isQueryResult);
if (properties != null) {
result.put(JSON_OBJECT_PROPERTIES, properties);
}
@@ -850,14 +849,14 @@ public class JSONConverter {
JSONArray relationships = new JSONArray();
for (ObjectData relationship : object.getRelationships()) {
- relationships.add(convert(relationship, typeCache));
+ relationships.add(convert(relationship, typeCache, false));
}
result.put(JSON_OBJECT_RELATIONSHIPS, relationships);
}
// change event info
- if (object.getChangeEventInfo() != null) {
+ if (object.getChangeEventInfo() != null && !isQueryResult) {
JSONObject changeEventInfo = new JSONObject();
ChangeEventInfo cei = object.getChangeEventInfo();
@@ -868,7 +867,7 @@ public class JSONConverter {
}
// ACL
- if ((object.getAcl() != null) && (object.getAcl().getAces() != null)) {
+ if ((object.getAcl() != null) && (object.getAcl().getAces() != null) && !isQueryResult) {
result.put(JSON_OBJECT_ACL, convert(object.getAcl()));
result.put(JSON_OBJECT_EXACT_ACL, object.isExactAcl());
}
@@ -904,7 +903,7 @@ public class JSONConverter {
* Converts a bag of properties.
*/
@SuppressWarnings("unchecked")
- public static JSONObject convert(Properties properties, String objectId, TypeCache typeCache) {
+ public static JSONObject convert(Properties properties, String objectId, TypeCache typeCache, boolean isQueryResult) {
if (properties == null) {
return null;
}
@@ -922,7 +921,7 @@ public class JSONConverter {
propDef = type.getPropertyDefinitions().get(property.getId());
}
- result.put(property.getId(), convert(property, propDef));
+ result.put((isQueryResult ? property.getQueryName() : property.getId()), convert(property, propDef));
}
convertExtension(properties, result);
@@ -1072,7 +1071,7 @@ public class JSONConverter {
* Converts a query object list.
*/
@SuppressWarnings("unchecked")
- public static JSONObject convert(ObjectList list, TypeCache typeCache) {
+ public static JSONObject convert(ObjectList list, TypeCache typeCache, boolean isQueryResult) {
if (list == null) {
return null;
}
@@ -1082,7 +1081,7 @@ public class JSONConverter {
JSONArray objects = new JSONArray();
if (list.getObjects() != null) {
for (ObjectData object : list.getObjects()) {
- objects.add(convert(object, typeCache));
+ objects.add(convert(object, typeCache, isQueryResult));
}
}
@@ -1106,7 +1105,7 @@ public class JSONConverter {
}
JSONObject result = new JSONObject();
- result.put(JSON_OBJECTINFOLDER_OBJECT, convert(objectInFolder.getObject(), typeCache));
+ result.put(JSON_OBJECTINFOLDER_OBJECT, convert(objectInFolder.getObject(), typeCache, false));
setIfNotNull(JSON_OBJECTINFOLDER_PATH_SEGMENT, objectInFolder.getPathSegment(), result);
convertExtension(objectInFolder, result);
@@ -1179,7 +1178,7 @@ public class JSONConverter {
}
JSONObject result = new JSONObject();
- result.put(JSON_OBJECTPARENTS_OBJECT, convert(parent.getObject(), typeCache));
+ result.put(JSON_OBJECTPARENTS_OBJECT, convert(parent.getObject(), typeCache, false));
if (parent.getRelativePathSegment() != null) {
result.put(JSON_OBJECTPARENTS_RELATIVE_PATH_SEGMENT, parent.getRelativePathSegment());
}
@@ -2053,6 +2052,61 @@ public class JSONConverter {
// -----------------------------------------------------------------
+ /**
+ * Converts FailedToDelete ids.
+ */
+ @SuppressWarnings("unchecked")
+ public static JSONObject convert(FailedToDeleteData ftd) {
+ if (ftd == null) {
+ return null;
+ }
+
+ JSONObject result = new JSONObject();
+
+ JSONArray ids = new JSONArray();
+ if (ftd.getIds() != null) {
+ for (String id : ftd.getIds()) {
+ ids.add(id);
+ }
+ }
+
+ result.put(JSON_FAILEDTODELETE_ID, ids);
+
+ convertExtension(ftd, result);
+
+ return result;
+ }
+
+ /**
+ * Converts FailedToDelete ids.
+ */
+ public static FailedToDeleteData convertFailedToDelete(Map<String, Object> json) {
+ if (json == null) {
+ return null;
+ }
+
+ FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();
+
+ List<String> ids = new ArrayList<String>();
+ List<Object> jsonIds = getList(json.get(JSON_FAILEDTODELETE_ID));
+
+ if (jsonIds != null) {
+ for (Object obj : jsonIds) {
+ if (obj != null) {
+ ids.add(obj.toString());
+ }
+ }
+ }
+
+ result.setIds(ids);
+
+ convertExtension(json, result, FAILEDTODELETE_KEYS);
+
+ return result;
+ }
+
+ // -----------------------------------------------------------------
+
@SuppressWarnings("unchecked")
public static void convertExtension(ExtensionsData source, JSONObject target) {
if (source == null || source.getExtensions() == null) {
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=1235671&r1=1235670&r2=1235671&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 Jan 25 07:58:25 2012
@@ -37,6 +37,7 @@ import static org.apache.chemistry.openc
import static org.apache.chemistry.opencmis.commons.impl.Constants.CMISACTION_REMOVE_OBJECT_FROM_FOLDER;
import static org.apache.chemistry.opencmis.commons.impl.Constants.CMISACTION_REMOVE_POLICY;
import static org.apache.chemistry.opencmis.commons.impl.Constants.CMISACTION_SET_CONTENT;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.CMISACTION_UPDATE_PROPERTIES;
import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_OBJECT_ID;
import static org.apache.chemistry.opencmis.commons.impl.Constants.SELECTOR_ACL;
import static org.apache.chemistry.opencmis.commons.impl.Constants.SELECTOR_ALLOWABLEACTIONS;
@@ -194,6 +195,8 @@ public class CmisBrowserBindingServlet e
"createDocumentFromSource");
rootDispatcher.addResource(CMISACTION_CREATE_FOLDER, METHOD_POST, ObjectService.class, "createFolder");
rootDispatcher.addResource(CMISACTION_CREATE_POLICY, METHOD_POST, ObjectService.class, "createPolicy");
+ rootDispatcher.addResource(CMISACTION_UPDATE_PROPERTIES, METHOD_POST, ObjectService.class,
+ "updateProperties");
rootDispatcher.addResource(CMISACTION_SET_CONTENT, METHOD_POST, ObjectService.class, "setContentStream");
rootDispatcher.addResource(CMISACTION_DELETE_CONTENT, METHOD_POST, ObjectService.class,
"deleteContentStream");
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/DiscoveryService.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/DiscoveryService.java?rev=1235671&r1=1235670&r2=1235671&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/DiscoveryService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/DiscoveryService.java Wed Jan 25 07:58:25 2012
@@ -37,6 +37,7 @@ import org.apache.chemistry.opencmis.com
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.impl.JSONConstants;
import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
import org.apache.chemistry.opencmis.commons.impl.TypeCache;
import org.apache.chemistry.opencmis.commons.server.CallContext;
@@ -76,7 +77,7 @@ public class DiscoveryService {
}
TypeCache typeCache = new TypeCache(repositoryId, service);
- JSONObject jsonResults = JSONConverter.convert(results, typeCache);
+ JSONObject jsonResults = JSONConverter.convert(results, typeCache, true);
response.setStatus(HttpServletResponse.SC_OK);
BrowserBindingUtils.writeJSON(jsonResults, request, response);
@@ -100,11 +101,9 @@ public class DiscoveryService {
ObjectList changes = service.getContentChanges(repositoryId, changeLogTokenHolder, includeProperties, filter,
includePolicyIds, includeAcl, maxItems, null);
- JSONObject jsonChanges = new JSONObject();
- jsonChanges.put("changeLogToken", changeLogTokenHolder.getValue());
-
TypeCache typeCache = new TypeCache(repositoryId, service);
- jsonChanges.put("objects", JSONConverter.convert(changes, typeCache));
+ JSONObject jsonChanges = JSONConverter.convert(changes, typeCache, false);
+ jsonChanges.put(JSONConstants.JSON_OBJECTLIST_CHANGE_LOG_TOKEN, changeLogTokenHolder.getValue());
response.setStatus(HttpServletResponse.SC_OK);
BrowserBindingUtils.writeJSON(jsonChanges, request, response);
Modified: 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=1235671&r1=1235670&r2=1235671&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/MultiFilingService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/MultiFilingService.java Wed Jan 25 07:58:25 2012
@@ -75,7 +75,7 @@ public class MultiFilingService {
// return object
TypeCache typeCache = new TypeCache(repositoryId, service);
- JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+ JSONObject jsonObject = JSONConverter.convert(object, typeCache, false);
writeJSON(jsonObject, request, response);
}
@@ -108,7 +108,7 @@ public class MultiFilingService {
// return object
TypeCache typeCache = new TypeCache(repositoryId, service);
- JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+ JSONObject jsonObject = JSONConverter.convert(object, typeCache, false);
writeJSON(jsonObject, request, response);
}
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=1235671&r1=1235670&r2=1235671&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 Wed Jan 25 07:58:25 2012
@@ -180,7 +180,7 @@ public final class NavigationService {
}
TypeCache typeCache = new TypeCache(repositoryId, service);
- JSONObject jsonObject = JSONConverter.convert(parent, typeCache);
+ JSONObject jsonObject = JSONConverter.convert(parent, typeCache, false);
response.setStatus(HttpServletResponse.SC_OK);
BrowserBindingUtils.writeJSON(jsonObject, request, response);
@@ -244,7 +244,7 @@ public final class NavigationService {
}
TypeCache typeCache = new TypeCache(repositoryId, service);
- JSONObject jsonCheckedOut = JSONConverter.convert(checkedout, typeCache);
+ JSONObject jsonCheckedOut = JSONConverter.convert(checkedout, typeCache, false);
response.setStatus(HttpServletResponse.SC_OK);
BrowserBindingUtils.writeJSON(jsonCheckedOut, request, response);
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=1235671&r1=1235670&r2=1235671&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 Jan 25 07:58:25 2012
@@ -62,11 +62,13 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.data.AllowableActions;
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.data.Properties;
+import org.apache.chemistry.opencmis.commons.data.PropertyData;
import org.apache.chemistry.opencmis.commons.data.RenditionData;
import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
@@ -116,7 +118,7 @@ public final class ObjectService {
}
// return object
- JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+ JSONObject jsonObject = JSONConverter.convert(object, typeCache, false);
response.setStatus(HttpServletResponse.SC_CREATED);
setCookie(request, response, repositoryId, transaction,
@@ -140,9 +142,15 @@ public final class ObjectService {
ControlParser cp = new ControlParser(request);
TypeCache typeCache = new TypeCache(repositoryId, service);
+ ObjectData sourceDoc = getSimpleObject(service, repositoryId, sourceId);
+ PropertyData<?> sourceTypeId = sourceDoc.getProperties().getProperties().get(PropertyIds.OBJECT_TYPE_ID);
+ if (sourceTypeId == null || sourceTypeId.getFirstValue() == null) {
+ throw new CmisRuntimeException("Source object has no type!?!");
+ }
+
String newObjectId = service.createDocumentFromSource(repositoryId, sourceId,
- createProperties(cp, null, typeCache), folderId, versioningState, createPolicies(cp), createAddAcl(cp),
- createRemoveAcl(cp), null);
+ createProperties(cp, sourceTypeId.getFirstValue().toString(), typeCache), folderId, versioningState,
+ createPolicies(cp), createAddAcl(cp), createRemoveAcl(cp), null);
ObjectData object = getSimpleObject(service, repositoryId, newObjectId);
if (object == null) {
@@ -150,7 +158,7 @@ public final class ObjectService {
}
// return object
- JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+ JSONObject jsonObject = JSONConverter.convert(object, typeCache, false);
response.setStatus(HttpServletResponse.SC_CREATED);
setCookie(request, response, repositoryId, transaction,
@@ -181,7 +189,7 @@ public final class ObjectService {
}
// return object
- JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+ JSONObject jsonObject = JSONConverter.convert(object, typeCache, false);
response.setStatus(HttpServletResponse.SC_CREATED);
setCookie(request, response, repositoryId, transaction,
@@ -212,7 +220,7 @@ public final class ObjectService {
}
// return object
- JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+ JSONObject jsonObject = JSONConverter.convert(object, typeCache, false);
response.setStatus(HttpServletResponse.SC_CREATED);
setCookie(request, response, repositoryId, transaction,
@@ -242,7 +250,7 @@ public final class ObjectService {
}
// return object
- JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+ JSONObject jsonObject = JSONConverter.convert(object, typeCache, false);
response.setStatus(HttpServletResponse.SC_CREATED);
setCookie(request, response, repositoryId, transaction,
@@ -279,7 +287,7 @@ public final class ObjectService {
}
// return object
- JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+ JSONObject jsonObject = JSONConverter.convert(object, typeCache, false);
int status = HttpServletResponse.SC_OK;
if (!objectId.equals(newObjectId)) {
@@ -318,7 +326,7 @@ public final class ObjectService {
// return object
TypeCache typeCache = new TypeCache(repositoryId, service);
- JSONObject jsonObject = JSONConverter.convert(properties, objectId, typeCache);
+ JSONObject jsonObject = JSONConverter.convert(properties, objectId, typeCache, false);
response.setStatus(HttpServletResponse.SC_OK);
writeJSON(jsonObject, request, response);
@@ -358,7 +366,7 @@ public final class ObjectService {
// return object
TypeCache typeCache = new TypeCache(repositoryId, service);
- JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+ JSONObject jsonObject = JSONConverter.convert(object, typeCache, false);
response.setStatus(HttpServletResponse.SC_OK);
writeJSON(jsonObject, request, response);
@@ -483,11 +491,14 @@ public final class ObjectService {
FailedToDeleteData ftd = service.deleteTree(repositoryId, objectId, allVersions, unfileObjects,
continueOnFailure, null);
+ response.setStatus(HttpServletResponse.SC_OK);
+
if ((ftd != null) && (ftd.getIds() != null) && (ftd.getIds().size() > 0)) {
- // TODO
+ JSONObject jsonObject = JSONConverter.convert(ftd);
+ writeJSON(jsonObject, request, response);
+ return;
}
- response.setStatus(HttpServletResponse.SC_OK);
writeEmpty(request, response);
}
@@ -516,7 +527,7 @@ public final class ObjectService {
// return object
TypeCache typeCache = new TypeCache(repositoryId, service);
- JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+ JSONObject jsonObject = JSONConverter.convert(object, typeCache, false);
writeJSON(jsonObject, request, response);
}
@@ -552,7 +563,7 @@ public final class ObjectService {
// return object
TypeCache typeCache = new TypeCache(repositoryId, service);
- JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+ JSONObject jsonObject = JSONConverter.convert(object, typeCache, false);
writeJSON(jsonObject, request, response);
}
@@ -586,7 +597,7 @@ public final class ObjectService {
// return object
TypeCache typeCache = new TypeCache(repositoryId, service);
- JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+ JSONObject jsonObject = JSONConverter.convert(object, typeCache, false);
writeJSON(jsonObject, request, response);
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.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/POSTHttpServletRequestWrapper.java?rev=1235671&r1=1235670&r2=1235671&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java Wed Jan 25 07:58:25 2012
@@ -19,6 +19,8 @@
package org.apache.chemistry.opencmis.server.impl.browser;
import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URLDecoder;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
@@ -49,27 +51,16 @@ public class POSTHttpServletRequestWrapp
public POSTHttpServletRequestWrapper(HttpServletRequest request, int memoryThreshold) throws Exception {
super(request);
- isMultipart = ServletFileUpload.isMultipartContent(request);
+ parameters = new HashMap<String, String[]>();
- if (isMultipart) {
- parameters = new HashMap<String, String[]>();
+ // parse query string
+ parseFormData(request.getQueryString());
- String query = request.getQueryString();
- if (query != null) {
- String[] nameValuePairs = query.split("&");
- for (String nameValuePair : nameValuePairs) {
- if (nameValuePair.length() > Constants.PARAM_OBJECT_ID.length()
- && nameValuePair.toLowerCase().startsWith(Constants.PARAM_OBJECT_ID.toLowerCase())) {
- int x = nameValuePair.indexOf('=');
- if (x > -1 && x < nameValuePair.length() - 1) {
- String objectId = nameValuePair.substring(x + 1);
- parameters.put(Constants.PARAM_OBJECT_ID, new String[] { objectId });
- break;
- }
- }
- }
- }
+ // check multipart
+ isMultipart = ServletFileUpload.isMultipartContent(request);
+ if (isMultipart) {
+ // multipart processing
DiskFileItemFactory itemFactory = new DiskFileItemFactory();
itemFactory.setSizeThreshold(memoryThreshold);
@@ -79,16 +70,7 @@ public class POSTHttpServletRequestWrapp
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);
- }
+ addParameter(item.getFieldName(), item.getString());
} else {
filename = item.getName();
contentType = (item.getContentType() == null ? Constants.MEDIATYPE_OCTETSTREAM : item
@@ -107,15 +89,53 @@ public class POSTHttpServletRequestWrapp
if ((contentTypeControl != null) && (contentTypeControl.trim().length() > 0)) {
contentType = contentTypeControl;
}
+ } else {
+ // form data processing
+ StringBuilder sb = new StringBuilder();
+
+ InputStreamReader sr = new InputStreamReader(request.getInputStream(), "UTF-8");
+ char[] buffer = new char[4096];
+ int c = 0;
+ while ((c = sr.read(buffer)) > -1) {
+ sb.append(buffer, 0, c);
+ }
+
+ parseFormData(sb.toString());
}
}
- @Override
- public String getParameter(String name) {
- if (!isMultipart) {
- return super.getParameter(name);
+ private void parseFormData(String data) throws Exception {
+ if (data == null || data.length() < 3) {
+ return;
+ }
+
+ String[] nameValuePairs = data.split("&");
+ for (String nameValuePair : nameValuePairs) {
+ int x = nameValuePair.indexOf('=');
+ if (x > 0) {
+ String name = URLDecoder.decode(nameValuePair.substring(0, x), "UTF-8");
+ String value = (x == nameValuePair.length() - 1 ? "" : URLDecoder.decode(
+ nameValuePair.substring(x + 1), "UTF-8"));
+ addParameter(name, value);
+ }
}
+ }
+
+ private void addParameter(String name, String value) {
+ String[] values = parameters.get(name);
+ if (values == null) {
+ parameters.put(name, new String[] { value });
+ } else {
+ String[] newValues = new String[values.length + 1];
+ System.arraycopy(values, 0, newValues, 0, values.length);
+ newValues[newValues.length - 1] = value;
+ parameters.put(name, newValues);
+ }
+ }
+
+ @Override
+ public String getParameter(String name) {
String[] values = parameters.get(name);
if ((values == null) || (values.length == 0)) {
return null;
@@ -124,32 +144,18 @@ public class POSTHttpServletRequestWrapp
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);
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/PolicyService.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/PolicyService.java?rev=1235671&r1=1235670&r2=1235671&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/PolicyService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/PolicyService.java Wed Jan 25 07:58:25 2012
@@ -61,7 +61,7 @@ public class PolicyService {
if (policies != null) {
TypeCache typeCache = new TypeCache(repositoryId, service);
for (ObjectData policy : policies) {
- jsonPolicies.add(JSONConverter.convert(policy, typeCache));
+ jsonPolicies.add(JSONConverter.convert(policy, typeCache, false));
}
}
@@ -90,7 +90,7 @@ public class PolicyService {
response.setStatus(HttpServletResponse.SC_OK);
TypeCache typeCache = new TypeCache(repositoryId, service);
- JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+ JSONObject jsonObject = JSONConverter.convert(object, typeCache, false);
writeJSON(jsonObject, request, response);
}
@@ -116,7 +116,7 @@ public class PolicyService {
response.setStatus(HttpServletResponse.SC_OK);
TypeCache typeCache = new TypeCache(repositoryId, service);
- JSONObject jsonObject = JSONConverter.convert(object, typeCache);
+ JSONObject jsonObject = JSONConverter.convert(object, typeCache, false);
writeJSON(jsonObject, request, response);
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RelationshipService.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/RelationshipService.java?rev=1235671&r1=1235670&r2=1235671&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RelationshipService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RelationshipService.java Wed Jan 25 07:58:25 2012
@@ -72,7 +72,7 @@ public class RelationshipService {
}
TypeCache typeCache = new TypeCache(repositoryId, service);
- JSONObject jsonChildren = JSONConverter.convert(relationships, typeCache);
+ JSONObject jsonChildren = JSONConverter.convert(relationships, typeCache, false);
response.setStatus(HttpServletResponse.SC_OK);
BrowserBindingUtils.writeJSON(jsonChildren, request, response);