Author: jens
Date: Tue Mar 6 06:51:56 2012
New Revision: 1297351
URL: http://svn.apache.org/viewvc?rev=1297351&view=rev
Log:
add support for createFolder
Modified:
chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/cmislib.js
chemistry/playground/chemistry-opencmis-javascript-client/src/test/resources/testcmislib.js
Modified:
chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/cmislib.js
URL:
http://svn.apache.org/viewvc/chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/cmislib.js?rev=1297351&r1=1297350&r2=1297351&view=diff
==============================================================================
---
chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/cmislib.js
(original)
+++
chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/cmislib.js
Tue Mar 6 06:51:56 2012
@@ -212,27 +212,46 @@ function CmisSession(urlPrefix, reposito
});
};
- this.createDocument = function(name, typeId, folderId, cbFct) {
+ this.createDocument = function(name, typeId, folderId, customProperties,
cbFct) {
+ console.log("createDocument(), name: " + name + ", typeId: " + typeId
+ ", folderId: " + folderId);
+ return this.create(name, typeId, folderId, customProperties,
"createDocument", cbFct);
+ };
+
+ this.createFolder = function(name, typeId, folderId, customProperties,
cbFct) {
+ console.log("createFolder(), name: " + name + ", typeId: " + typeId +
", folderId: " + folderId);
+ return this.create(name, typeId, folderId, customProperties,
"createFolder", cbFct);
+ };
+
+ this.create = function(name, typeId, folderId, customProperties,
cmisAction, cbFct) {
var url = this.getRootUrl();
var properties = {
- cmisaction: "createDocument",
+ cmisaction: cmisAction,
objectId: folderId,
"propertyId[0]": "cmis:name",
"propertyValue[0]": name,
"propertyId[1]": "cmis:objectTypeId",
- "propertyValue[1]": typeId
+ "propertyValue[1]": typeId,
+ suppressResponseCodes: true
};
- console.log("createDocument(): " + url);
+ // add custom properties
+ if (null != customProperties) {
+ var i=1;
+ for (var customProp in customProperties) {
+ properties["propertyId[++i]"] = customProp;
+ properties["propertyValue[i]"] = customProperties[customProp];
+ }
+ }
+
$.ajax( {
url: url,
data: properties,
type: "POST",
- success: cbFct
+ success: cbFct
});
};
-
+
this.getTypeDefinition = function(typeId, cbFct) {
var url = this.getUrl();
var data = {
Modified:
chemistry/playground/chemistry-opencmis-javascript-client/src/test/resources/testcmislib.js
URL:
http://svn.apache.org/viewvc/chemistry/playground/chemistry-opencmis-javascript-client/src/test/resources/testcmislib.js?rev=1297351&r1=1297350&r2=1297351&view=diff
==============================================================================
---
chemistry/playground/chemistry-opencmis-javascript-client/src/test/resources/testcmislib.js
(original)
+++
chemistry/playground/chemistry-opencmis-javascript-client/src/test/resources/testcmislib.js
Tue Mar 6 06:51:56 2012
@@ -140,7 +140,7 @@ test("testCreateDeleteDocument", functio
});
stop(2);
- this.session.createDocument("UnitTestDocument", "cmis:document",
this.session.rootFolderId, function(data) {
+ this.session.createDocument("UnitTestDocument", "cmis:document",
this.session.rootFolderId, null, function(data) {
ok(data.exception == null, "CreateDocument()");
ok(data.properties["cmis:objectId"].value != null, "Document has
id");
docId = data.properties["cmis:objectId"].value;
@@ -173,9 +173,9 @@ test("testCreateDocumentMustFail()", fun
});
stop(3);
- this.session.createDocument("UnitTestDocument", "cmis:document",
this.session.rootFolderId, function(data) {
+ this.session.createDocument("UnitTestDocument", "cmis:document",
this.session.rootFolderId, null, function(data) {
docId = data.properties["cmis:objectId"].value;
- ctx.session.createDocument("UnitTestDocument", "cmis:document",
ctx.session.rootFolderId, function(data) {
+ ctx.session.createDocument("UnitTestDocument", "cmis:document",
ctx.session.rootFolderId, null, function(data) {
ok(false, "CreateDocument() called twice with same name should
fail");
start();
});