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/08 00:16:14 UTC
svn commit: r1199004 - 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: Mon Nov 7 23:16:13 2011
New Revision: 1199004
URL: http://svn.apache.org/viewvc?rev=1199004&view=rev
Log:
even more browser binding code - mostly untested
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
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.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=1199004&r1=1199003&r2=1199004&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 Mon Nov 7 23:16:13 2011
@@ -20,9 +20,6 @@ package org.apache.chemistry.opencmis.co
/**
* Constants for CMIS server and client.
- *
- * @author <a href="mailto:fmueller@opentext.com">Florian Müller</a>
- *
*/
public final class Constants {
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=1199004&r1=1199003&r2=1199004&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java Mon Nov 7 23:16:13 2011
@@ -80,6 +80,8 @@ public class BrowserBindingUtils {
public static final String SELECTOR_CONTENT = "content";
public static final String SELECTOR_OBJECT = "object";
+ public static final String SELECTOR_PROPERTIES = "properties";
+ public static final String SELECTOR_RENDITIONS = "renditions";
public static final String SELECTOR_CHILDREN = "children";
public static final String SELECTOR_DESCENDANTS = "descendants";
public static final String SELECTOR_PARENTS = "parents";
@@ -87,6 +89,7 @@ public class BrowserBindingUtils {
public static final String SELECTOR_FOLDER_TREE = "folder";
public static final String SELECTOR_QUERY = "query";
public static final String SELECTOR_VERSIONS = "versions";
+ public static final String SELECTOR_RELATIONSHIPS = "relationships";
public static final String CMISACTION_CREATE_DOCUMENT = "createDocument";
public static final String CMISACTION_CREATE_FOLDER = "createFolder";
@@ -101,6 +104,7 @@ public class BrowserBindingUtils {
public static final String PARAM_SELECTOR = "selector";
public static final String PARAM_TRANSACTION = "transaction";
public static final String PARAM_CLIENT_TOKEN = "clientToken";
+ public static final String PARAM_SUPPRESS_RESPONSE_CODES ="suppressResponseCodes";
public static final String CONTROL_CMISACTION = "cmisaction";
public static final String CONTROL_TRANSACTION = "transaction";
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=1199004&r1=1199003&r2=1199004&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java Mon Nov 7 23:16:13 2011
@@ -25,7 +25,6 @@ import static org.apache.chemistry.openc
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_DELETE_CONTENT;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_DELETE_TREE;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_QUERY;
-import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.SELECTOR_PARENT;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CMISACTION_SET_CONTENT;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CONTEXT_BASETYPE_ID;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CONTEXT_TRANSACTION;
@@ -34,14 +33,19 @@ import static org.apache.chemistry.openc
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CONTROL_TRANSACTION;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.JSON_MIME_TYPE;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.PARAM_SELECTOR;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.PARAM_SUPPRESS_RESPONSE_CODES;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.SELECTOR_CHILDREN;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.SELECTOR_CONTENT;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.SELECTOR_DESCENDANTS;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.SELECTOR_FOLDER_TREE;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.SELECTOR_LAST_RESULT;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.SELECTOR_OBJECT;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.SELECTOR_PARENT;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.SELECTOR_PARENTS;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.SELECTOR_PROPERTIES;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.SELECTOR_QUERY;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.SELECTOR_RELATIONSHIPS;
+import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.SELECTOR_RENDITIONS;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.SELECTOR_TYPE_CHILDREN;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.SELECTOR_TYPE_DEFINITION;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.SELECTOR_TYPE_DESCENDANTS;
@@ -55,6 +59,7 @@ import static org.apache.chemistry.openc
import static org.apache.chemistry.opencmis.server.impl.browser.json.JSONConstants.ERROR_STACKTRACE;
import static org.apache.chemistry.opencmis.server.shared.Dispatcher.METHOD_GET;
import static org.apache.chemistry.opencmis.server.shared.Dispatcher.METHOD_POST;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBooleanParameter;
import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
import java.io.IOException;
@@ -141,6 +146,8 @@ public class CmisBrowserBindingServlet e
"createDocument");
rootDispatcher.addResource(SELECTOR_OBJECT, METHOD_GET, ObjectService.class, "getObject");
+ rootDispatcher.addResource(SELECTOR_PROPERTIES, METHOD_GET, ObjectService.class, "getProperties");
+ rootDispatcher.addResource(SELECTOR_RENDITIONS, METHOD_GET, ObjectService.class, "getRenditions");
rootDispatcher.addResource(SELECTOR_CONTENT, METHOD_GET, ObjectService.class, "getContentStream");
rootDispatcher.addResource(SELECTOR_CHILDREN, METHOD_GET, NavigationService.class, "getChildren");
rootDispatcher.addResource(SELECTOR_DESCENDANTS, METHOD_GET, NavigationService.class, "getDescendants");
@@ -148,6 +155,8 @@ public class CmisBrowserBindingServlet e
rootDispatcher.addResource(SELECTOR_PARENT, METHOD_GET, NavigationService.class, "getFolderParent");
rootDispatcher.addResource(SELECTOR_PARENTS, METHOD_GET, NavigationService.class, "getObjectParents");
rootDispatcher.addResource(SELECTOR_VERSIONS, METHOD_GET, VersioningService.class, "getAllVersions");
+ rootDispatcher.addResource(SELECTOR_RELATIONSHIPS, METHOD_GET, RelationshipService.class,
+ "getObjectRelationships");
rootDispatcher.addResource(CMISACTION_CREATE_DOCUMENT, METHOD_POST, ObjectService.class, "createDocument");
rootDispatcher.addResource(CMISACTION_CREATE_FOLDER, METHOD_POST, ObjectService.class, "createFolder");
@@ -361,6 +370,10 @@ public class CmisBrowserBindingServlet e
LOG.error(ex.getMessage(), ex);
}
+ if (getBooleanParameter(request, PARAM_SUPPRESS_RESPONSE_CODES, false)) {
+ statusCode = HttpServletResponse.SC_OK;
+ }
+
response.setStatus(statusCode);
response.setContentType(JSON_MIME_TYPE);
if (context != null) {
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=1199004&r1=1199003&r2=1199004&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java Mon Nov 7 23:16:13 2011
@@ -41,6 +41,7 @@ import static org.apache.chemistry.openc
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createRemoveAcl;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.setCookie;
import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.writeJSON;
+import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBigIntegerParameter;
import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBooleanParameter;
import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getEnumParameter;
import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
@@ -50,6 +51,7 @@ import java.io.BufferedOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigInteger;
+import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -57,6 +59,8 @@ import javax.servlet.http.HttpServletRes
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.RenditionData;
import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
@@ -68,6 +72,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.server.ObjectInfo;
import org.apache.chemistry.opencmis.commons.spi.Holder;
import org.apache.chemistry.opencmis.server.impl.browser.json.JSONConverter;
+import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
/**
@@ -80,6 +85,9 @@ public final class ObjectService {
private ObjectService() {
}
+ /**
+ * Create document.
+ */
public static void createDocument(CallContext context, CmisService service, String repositoryId,
HttpServletRequest request, HttpServletResponse response) throws Exception {
// get parameters
@@ -114,6 +122,9 @@ public final class ObjectService {
writeJSON(jsonObject, request, response);
}
+ /**
+ * Create folder.
+ */
public static void createFolder(CallContext context, CmisService service, String repositoryId,
HttpServletRequest request, HttpServletResponse response) throws Exception {
// get parameters
@@ -146,6 +157,40 @@ public final class ObjectService {
writeJSON(jsonObject, request, response);
}
+ /**
+ * getProperties.
+ */
+ public static void getProperties(CallContext context, CmisService service, String repositoryId,
+ HttpServletRequest request, HttpServletResponse response) throws Exception {
+ // get parameters
+ String objectId = (String) context.get(CONTEXT_OBJECT_ID);
+ ReturnVersion returnVersion = getEnumParameter(request, PARAM_RETURN_VERSION, ReturnVersion.class);
+ String filter = getStringParameter(request, PARAM_FILTER);
+
+ // execute
+ Properties properties;
+
+ if (returnVersion == ReturnVersion.LATEST || returnVersion == ReturnVersion.LASTESTMAJOR) {
+ properties = service.getPropertiesOfLatestVersion(repositoryId, objectId, null,
+ returnVersion == ReturnVersion.LASTESTMAJOR, filter, null);
+ } else {
+ properties = service.getProperties(repositoryId, objectId, filter, null);
+ }
+
+ if (properties == null) {
+ throw new CmisRuntimeException("Properties are null!");
+ }
+
+ TypeCache typeCache = new TypeCache(repositoryId, service);
+ JSONObject jsonObject = JSONConverter.convert(properties, objectId, typeCache);
+
+ response.setStatus(HttpServletResponse.SC_OK);
+ writeJSON(jsonObject, request, response);
+ }
+
+ /**
+ * getObject.
+ */
public static void getObject(CallContext context, CmisService service, String repositoryId,
HttpServletRequest request, HttpServletResponse response) throws Exception {
// get parameters
@@ -182,6 +227,37 @@ public final class ObjectService {
writeJSON(jsonObject, request, response);
}
+ /**
+ * getRenditions.
+ */
+ @SuppressWarnings("unchecked")
+ public static void getRenditions(CallContext context, CmisService service, String repositoryId,
+ HttpServletRequest request, HttpServletResponse response) throws Exception {
+ // get parameters
+ String objectId = (String) context.get(CONTEXT_OBJECT_ID);
+ String renditionFilter = getStringParameter(request, PARAM_RENDITION_FILTER);
+ BigInteger maxItems = getBigIntegerParameter(request, Constants.PARAM_MAX_ITEMS);
+ BigInteger skipCount = getBigIntegerParameter(request, Constants.PARAM_SKIP_COUNT);
+
+ // execute
+
+ List<RenditionData> renditions = service.getRenditions(repositoryId, objectId, renditionFilter, maxItems,
+ skipCount, null);
+
+ JSONArray jsonRenditions = new JSONArray();
+ if (renditions != null) {
+ for (RenditionData rendition : renditions) {
+ jsonRenditions.add(JSONConverter.convert(rendition));
+ }
+ }
+
+ response.setStatus(HttpServletResponse.SC_OK);
+ writeJSON(jsonRenditions, request, response);
+ }
+
+ /**
+ * getContentStream.
+ */
public static void getContentStream(CallContext context, CmisService service, String repositoryId,
HttpServletRequest request, HttpServletResponse response) throws Exception {
// get parameters
@@ -225,6 +301,9 @@ public final class ObjectService {
out.flush();
}
+ /**
+ * deleteObject.
+ */
public static void deleteObject(CallContext context, CmisService service, String repositoryId,
HttpServletRequest request, HttpServletResponse response) throws Exception {
// get parameters
@@ -236,6 +315,9 @@ public final class ObjectService {
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
+ /**
+ * deleteTree.
+ */
public static void deleteTree(CallContext context, CmisService service, String repositoryId,
HttpServletRequest request, HttpServletResponse response) throws Exception {
// get parameters
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java?rev=1199004&r1=1199003&r2=1199004&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/json/JSONConverter.java Mon Nov 7 23:16:13 2011
@@ -38,6 +38,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.data.ObjectList;
import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
import org.apache.chemistry.opencmis.commons.data.PermissionMapping;
+import org.apache.chemistry.opencmis.commons.data.Properties;
import org.apache.chemistry.opencmis.commons.data.PropertyBoolean;
import org.apache.chemistry.opencmis.commons.data.PropertyData;
import org.apache.chemistry.opencmis.commons.data.PropertyDateTime;
@@ -222,23 +223,10 @@ public class JSONConverter {
// properties
if (object.getProperties() != null) {
- JSONObject properties = new JSONObject();
-
- for (PropertyData<?> property : object.getProperties().getPropertyList()) {
- TypeDefinition type = null;
- if (typeCache != null) {
- type = typeCache.getTypeDefinitionForObject(object.getId());
- }
-
- PropertyDefinition<?> propDef = null;
- if (type != null) {
- propDef = type.getPropertyDefinitions().get(property.getId());
- }
-
- properties.put(property.getId(), convert(property, propDef));
+ JSONObject properties = convert(object.getProperties(), object.getId(), typeCache);
+ if (properties != null) {
+ result.put(JSON_OBJECT_PROPERTIES, properties);
}
-
- result.put(JSON_OBJECT_PROPERTIES, properties);
}
// allowable actions
@@ -300,6 +288,34 @@ public class JSONConverter {
}
/**
+ * Converts a bag of properties.
+ */
+ @SuppressWarnings("unchecked")
+ public static JSONObject convert(Properties properties, String objectId, TypeCache typeCache) {
+ if (properties == null) {
+ return null;
+ }
+
+ JSONObject result = new JSONObject();
+
+ for (PropertyData<?> property : properties.getPropertyList()) {
+ TypeDefinition type = null;
+ if (typeCache != null) {
+ type = typeCache.getTypeDefinitionForObject(objectId);
+ }
+
+ PropertyDefinition<?> propDef = null;
+ if (type != null) {
+ propDef = type.getPropertyDefinitions().get(property.getId());
+ }
+
+ result.put(property.getId(), convert(property, propDef));
+ }
+
+ return result;
+ }
+
+ /**
* Converts a property.
*/
@SuppressWarnings("unchecked")