Author: fmui
Date: Thu Dec 6 19:42:42 2012
New Revision: 1418042
URL: http://svn.apache.org/viewvc?rev=1418042&view=rev
Log:
more CMIS 1.1 code
Modified:
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/ObjectServiceImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/NewTypeSettableAttributes.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-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/NewTypeSettableAttributesImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-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=1418042&r1=1418041&r2=1418042&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
Thu Dec 6 19:42:42 2012
@@ -30,6 +30,7 @@ import java.util.Map;
import org.apache.chemistry.opencmis.commons.data.Ace;
import org.apache.chemistry.opencmis.commons.data.Acl;
+import
org.apache.chemistry.opencmis.commons.data.BulkUpdateObjectIdAndChangeToken;
import org.apache.chemistry.opencmis.commons.data.ContentStream;
import org.apache.chemistry.opencmis.commons.data.Properties;
import org.apache.chemistry.opencmis.commons.data.PropertyData;
@@ -151,6 +152,52 @@ public class FormDataWriter {
}
}
+ public void
addObjectIdsAndChangeTokens(List<BulkUpdateObjectIdAndChangeToken>
objectIdsAndChangeTokens) {
+ if (objectIdsAndChangeTokens == null ||
objectIdsAndChangeTokens.size() == 0) {
+ return;
+ }
+
+ int idx = 0;
+ for (BulkUpdateObjectIdAndChangeToken oc : objectIdsAndChangeTokens) {
+ if (oc == null || oc.getId() == null || oc.getId().length() == 0) {
+ continue;
+ }
+
+ String idxStr = "[" + idx + "]";
+ addParameter(Constants.CONTROL_OBJECT_ID + idxStr, oc.getId());
+ addParameter(Constants.CONTROL_CHANGE_TOKEN + idxStr,
+ (oc.getChangeToken() == null ? "" : oc.getChangeToken()));
+
+ idx++;
+ }
+ }
+
+ public void addSecondaryTypeIds(List<String> secondaryTypeIds) {
+ addSecondaryTypeIdParameters(secondaryTypeIds,
Constants.CONTROL_ADD_SECONDARY_TYPE);
+ }
+
+ public void removeSecondaryTypeIds(List<String> secondaryTypeIds) {
+ addSecondaryTypeIdParameters(secondaryTypeIds,
Constants.CONTROL_REMOVE_SECONDARY_TYPE);
+ }
+
+ private void addSecondaryTypeIdParameters(List<String> secondaryTypeIds,
String secondaryTypeIdControl) {
+ if (secondaryTypeIds == null || secondaryTypeIds.size() == 0) {
+ return;
+ }
+
+ int idx = 0;
+ for (String typeId : secondaryTypeIds) {
+ if (typeId == null || typeId.length() == 0) {
+ continue;
+ }
+
+ String idxStr = "[" + idx + "]";
+ addParameter(secondaryTypeIdControl + idxStr, typeId);
+
+ idx++;
+ }
+ }
+
private String convertPropertyValue(Object value) {
if (value == null) {
return null;
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=1418042&r1=1418041&r2=1418042&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
Thu Dec 6 19:42:42 2012
@@ -39,7 +39,6 @@ import org.apache.chemistry.opencmis.com
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.exceptions.CmisNotSupportedException;
import org.apache.chemistry.opencmis.commons.impl.Constants;
import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
import org.apache.chemistry.opencmis.commons.impl.TypeCache;
@@ -392,7 +391,31 @@ public class ObjectServiceImpl extends A
public List<BulkUpdateObjectIdAndChangeToken> bulkUpdateProperties(String
repositoryId,
List<BulkUpdateObjectIdAndChangeToken> objectIdAndChangeToken,
Properties properties,
List<String> addSecondaryTypeIds, List<String>
removeSecondaryTypeIds, ExtensionsData extension) {
- throw new CmisNotSupportedException("Not supported!");
+ // we need object ids
+ if ((objectIdAndChangeToken == null) || (objectIdAndChangeToken.size()
== 0)) {
+ throw new CmisInvalidArgumentException("Object ids must be set!");
+ }
+
+ // build URL
+ UrlBuilder url = getRepositoryUrl(repositoryId);
+
+ // prepare form data
+ final FormDataWriter formData = new
FormDataWriter(Constants.CMISACTION_CREATE_DOCUMENT);
+ formData.addObjectIdsAndChangeTokens(objectIdAndChangeToken);
+ formData.addPropertiesParameters(properties);
+ formData.addSecondaryTypeIds(addSecondaryTypeIds);
+ formData.removeSecondaryTypeIds(removeSecondaryTypeIds);
+
+ // send and parse
+ HttpUtils.Response resp = post(url, formData.getContentType(), new
HttpUtils.Output() {
+ public void write(OutputStream out) throws Exception {
+ formData.write(out);
+ }
+ });
+
+ List<Object> json = parseArray(resp.getStream(), resp.getCharset());
+
+ return JSONConverter.convertBulkUpdate(json);
}
public void moveObject(String repositoryId, Holder<String> objectId,
String targetFolderId, String sourceFolderId,
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/NewTypeSettableAttributes.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/NewTypeSettableAttributes.java?rev=1418042&r1=1418041&r2=1418042&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/NewTypeSettableAttributes.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/NewTypeSettableAttributes.java
Thu Dec 6 19:42:42 2012
@@ -22,7 +22,7 @@ package org.apache.chemistry.opencmis.co
* A collection of flags that indicate which type attributes can be set at type
* creation.
*/
-public interface NewTypeSettableAttributes {
+public interface NewTypeSettableAttributes extends ExtensionsData {
/**
* Indicates if the "id" attribute can be set.
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=1418042&r1=1418041&r2=1418042&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
Thu Dec 6 19:42:42 2012
@@ -163,6 +163,9 @@ public final class Constants {
public static final String CONTROL_IS_LAST_CHUNK = "isLastChunk";
public static final String CONTROL_TYPE = "type";
public static final String CONTROL_TYPE_ID = "typeId";
+ public static final String CONTROL_CHANGE_TOKEN = "changeToken";
+ public static final String CONTROL_ADD_SECONDARY_TYPE =
"addSecondaryTypeId";
+ public static final String CONTROL_REMOVE_SECONDARY_TYPE =
"removeSecondaryTypeId";
// parameter
public static final String PARAM_ACL = "includeACL";
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=1418042&r1=1418041&r2=1418042&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
Thu Dec 6 19:42:42 2012
@@ -87,6 +87,8 @@ public final class JSONConstants {
public static final String JSON_CAP_QUERY = "capabilityQuery";
public static final String JSON_CAP_JOIN = "capabilityJoin";
public static final String JSON_CAP_ACL = "capabilityACL";
+ public static final String JSON_CAP_CREATABLE_PROPERTY_TYPES =
"capabilityCreatablePropertyTypes";
+ public static final String JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES =
"capabilityNewTypeSettableAttributes";
public static final Set<String> CAP_KEYS = new HashSet<String>();
static {
@@ -104,6 +106,45 @@ public final class JSONConstants {
CAP_KEYS.add(JSON_CAP_QUERY);
CAP_KEYS.add(JSON_CAP_JOIN);
CAP_KEYS.add(JSON_CAP_ACL);
+ CAP_KEYS.add(JSON_CAP_CREATABLE_PROPERTY_TYPES);
+ CAP_KEYS.add(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES);
+ }
+
+ public static final String JSON_CAP_CREATABLE_PROPERTY_TYPES_CANCREATE =
"canCreate";
+
+ public static final Set<String> CAP_CREATABLE_PROPERTY_TYPES_KEYS = new
HashSet<String>();
+ static {
+
CAP_CREATABLE_PROPERTY_TYPES_KEYS.add(JSON_CAP_CREATABLE_PROPERTY_TYPES_CANCREATE);
+ }
+
+ public static final String JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_ID = "id";
+ public static final String JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_LOCALNAME
= "localName";
+ public static final String
JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_LOCALNAMESPACE = "localNamespace";
+ public static final String
JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_DISPLAYNAME = "displayName";
+ public static final String JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_QUERYNAME
= "queryName";
+ public static final String
JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_DESCRIPTION = "description";
+ public static final String
JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_CREATEABLE = "creatable";
+ public static final String JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_FILEABLE
= "fileable";
+ public static final String JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_QUERYABLE
= "queryable";
+ public static final String
JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_FULLTEXTINDEXED = "fulltextIndexed";
+ public static final String
JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_INCLUDEDINSUPERTYTPEQUERY =
"includedInSupertypeQuery";
+ public static final String
JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_CONTROLABLEPOLICY = "controllablePolicy";
+ public static final String
JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_CONTROLABLEACL = "controllableACL";
+
+ public static final Set<String> CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_KEYS =
new HashSet<String>();
+ static {
+
CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_KEYS.add(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_ID);
+
CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_KEYS.add(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_LOCALNAME);
+
CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_KEYS.add(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_LOCALNAMESPACE);
+
CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_KEYS.add(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_DISPLAYNAME);
+
CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_KEYS.add(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_QUERYNAME);
+
CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_KEYS.add(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_DESCRIPTION);
+
CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_KEYS.add(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_CREATEABLE);
+
CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_KEYS.add(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_FILEABLE);
+
CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_KEYS.add(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_FULLTEXTINDEXED);
+
CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_KEYS.add(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_INCLUDEDINSUPERTYTPEQUERY);
+
CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_KEYS.add(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_CONTROLABLEPOLICY);
+
CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_KEYS.add(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_CONTROLABLEACL);
}
public static final String JSON_ACLCAP_SUPPORTED_PERMISSIONS =
"supportedPermissions";
@@ -453,6 +494,17 @@ public final class JSONConstants {
FAILEDTODELETE_KEYS.add(JSON_FAILEDTODELETE_ID);
}
+ public static final String JSON_BULK_UPDATE_ID = "id";
+ public static final String JSON_BULK_UPDATE_NEW_ID = "newId";
+ public static final String JSON_BULK_UPDATE_CHANGE_TOKEN = "changeToken";
+
+ public static final Set<String> BULK_UPDATE_KEYS = new HashSet<String>();
+ static {
+ BULK_UPDATE_KEYS.add(JSON_BULK_UPDATE_ID);
+ BULK_UPDATE_KEYS.add(JSON_BULK_UPDATE_NEW_ID);
+ BULK_UPDATE_KEYS.add(JSON_BULK_UPDATE_CHANGE_TOKEN);
+ }
+
// 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=1418042&r1=1418041&r2=1418042&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
Thu Dec 6 19:42:42 2012
@@ -38,10 +38,13 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.data.Acl;
import org.apache.chemistry.opencmis.commons.data.AclCapabilities;
import org.apache.chemistry.opencmis.commons.data.AllowableActions;
+import
org.apache.chemistry.opencmis.commons.data.BulkUpdateObjectIdAndChangeToken;
import org.apache.chemistry.opencmis.commons.data.ChangeEventInfo;
import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
+import org.apache.chemistry.opencmis.commons.data.CreatablePropertyTypes;
import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
import org.apache.chemistry.opencmis.commons.data.FailedToDeleteData;
+import org.apache.chemistry.opencmis.commons.data.NewTypeSettableAttributes;
import org.apache.chemistry.opencmis.commons.data.ObjectData;
import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
@@ -106,12 +109,16 @@ import org.apache.chemistry.opencmis.com
import
org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl;
import
org.apache.chemistry.opencmis.commons.impl.dataobjects.AclCapabilitiesDataImpl;
import
org.apache.chemistry.opencmis.commons.impl.dataobjects.AllowableActionsImpl;
+import
org.apache.chemistry.opencmis.commons.impl.dataobjects.BulkUpdateObjectIdAndChangeTokenImpl;
import
org.apache.chemistry.opencmis.commons.impl.dataobjects.ChangeEventInfoDataImpl;
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.CreatablePropertyTypesImpl;
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.ItemTypeDefinitionImpl;
+import
org.apache.chemistry.opencmis.commons.impl.dataobjects.NewTypeSettableAttributesImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectDataImpl;
import
org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderContainerImpl;
import
org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderDataImpl;
@@ -230,6 +237,60 @@ public final class JSONConverter {
result.put(JSON_CAP_JOIN,
getJSONStringValue(capabilities.getJoinCapability().value()));
result.put(JSON_CAP_ACL,
getJSONStringValue(capabilities.getAclCapability().value()));
+ if (capabilities.getCreatablePropertyTypes() != null) {
+ CreatablePropertyTypes creatablePropertyTypes =
capabilities.getCreatablePropertyTypes();
+
+ JSONObject creatablePropertyTypesJson = new JSONObject();
+
+ if (creatablePropertyTypes.canCreate() != null) {
+ JSONArray canCreate = new JSONArray();
+ for (PropertyType propType :
creatablePropertyTypes.canCreate()) {
+ canCreate.add(propType.value());
+ }
+
creatablePropertyTypesJson.put(JSON_CAP_CREATABLE_PROPERTY_TYPES_CANCREATE,
canCreate);
+ }
+
+ convertExtension(creatablePropertyTypes,
creatablePropertyTypesJson);
+
+ result.put(JSON_CAP_CREATABLE_PROPERTY_TYPES,
creatablePropertyTypesJson);
+ }
+
+ if (capabilities.getNewTypeSettableAttributes() != null) {
+ NewTypeSettableAttributes newTypeSettableAttributes =
capabilities.getNewTypeSettableAttributes();
+
+ JSONObject newTypeSettableAttributesJson = new JSONObject();
+
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_ID,
+ newTypeSettableAttributes.canSetId());
+
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_LOCALNAME,
+ newTypeSettableAttributes.canSetLocalName());
+
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_LOCALNAMESPACE,
+ newTypeSettableAttributes.canSetLocalNamespace());
+
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_DISPLAYNAME,
+ newTypeSettableAttributes.canSetDisplayName());
+
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_QUERYNAME,
+ newTypeSettableAttributes.canSetQueryName());
+
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_DESCRIPTION,
+ newTypeSettableAttributes.canSetDescription());
+
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_CREATEABLE,
+ newTypeSettableAttributes.canSetCreatable());
+
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_FILEABLE,
+ newTypeSettableAttributes.canSetFileable());
+
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_QUERYABLE,
+ newTypeSettableAttributes.canSetQueryable());
+
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_FULLTEXTINDEXED,
+ newTypeSettableAttributes.canSetFulltextIndexed());
+
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_INCLUDEDINSUPERTYTPEQUERY,
+
newTypeSettableAttributes.canSetIncludedInSupertypeQuery());
+
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_CONTROLABLEPOLICY,
+ newTypeSettableAttributes.canSetControllablePolicy());
+
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_CONTROLABLEACL,
+ newTypeSettableAttributes.canSetControllableAcl());
+
+ convertExtension(newTypeSettableAttributes,
newTypeSettableAttributesJson);
+
+ result.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES,
newTypeSettableAttributesJson);
+ }
+
convertExtension(capabilities, result);
return result;
@@ -357,6 +418,70 @@ public final class JSONConverter {
result.setCapabilityJoin(getEnum(json, JSON_CAP_JOIN,
CapabilityJoin.class));
result.setCapabilityAcl(getEnum(json, JSON_CAP_ACL,
CapabilityAcl.class));
+ Map<String, Object> creatablePropertyTypesJson =
getMap(json.get(JSON_CAP_CREATABLE_PROPERTY_TYPES));
+ if (creatablePropertyTypesJson != null) {
+ CreatablePropertyTypesImpl creatablePropertyTypes = new
CreatablePropertyTypesImpl();
+
+ List<Object> canCreateJson = getList(creatablePropertyTypesJson
+ .get(JSON_CAP_CREATABLE_PROPERTY_TYPES_CANCREATE));
+ if (canCreateJson != null) {
+ Set<PropertyType> canCreate = new HashSet<PropertyType>();
+
+ for (Object o : canCreateJson) {
+ try {
+ if (o != null) {
+
canCreate.add(PropertyType.fromValue(o.toString()));
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ creatablePropertyTypes.setCanCreate(canCreate);
+ }
+
+ convertExtension(creatablePropertyTypesJson,
creatablePropertyTypes, CAP_CREATABLE_PROPERTY_TYPES_KEYS);
+
+ result.setCreatablePropertyTypes(creatablePropertyTypes);
+ }
+
+ Map<String, Object> newTypeSettableAttributesJson =
getMap(json.get(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES));
+ if (newTypeSettableAttributesJson != null) {
+ NewTypeSettableAttributesImpl newTypeSettableAttributes = new
NewTypeSettableAttributesImpl();
+
+
newTypeSettableAttributes.setCanSetId(getBoolean(newTypeSettableAttributesJson,
+ JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_ID));
+
newTypeSettableAttributes.setCanSetLocalName(getBoolean(newTypeSettableAttributesJson,
+ JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_LOCALNAME));
+
newTypeSettableAttributes.setCanSetLocalNamespace(getBoolean(newTypeSettableAttributesJson,
+ JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_LOCALNAMESPACE));
+
newTypeSettableAttributes.setCanSetDisplayName(getBoolean(newTypeSettableAttributesJson,
+ JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_DISPLAYNAME));
+
newTypeSettableAttributes.setCanSetQueryName(getBoolean(newTypeSettableAttributesJson,
+ JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_QUERYNAME));
+
newTypeSettableAttributes.setCanSetDescription(getBoolean(newTypeSettableAttributesJson,
+ JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_DESCRIPTION));
+
newTypeSettableAttributes.setCanSetCreatable(getBoolean(newTypeSettableAttributesJson,
+ JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_CREATEABLE));
+
newTypeSettableAttributes.setCanSetFileable(getBoolean(newTypeSettableAttributesJson,
+ JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_FILEABLE));
+
newTypeSettableAttributes.setCanSetQueryable(getBoolean(newTypeSettableAttributesJson,
+ JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_QUERYABLE));
+
newTypeSettableAttributes.setCanSetFulltextIndexed(getBoolean(newTypeSettableAttributesJson,
+ JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_FULLTEXTINDEXED));
+
newTypeSettableAttributes.setCanSetIncludedInSupertypeQuery(getBoolean(newTypeSettableAttributesJson,
+
JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_INCLUDEDINSUPERTYTPEQUERY));
+
newTypeSettableAttributes.setCanSetControllablePolicy(getBoolean(newTypeSettableAttributesJson,
+ JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_CONTROLABLEPOLICY));
+
newTypeSettableAttributes.setCanSetControllableAcl(getBoolean(newTypeSettableAttributesJson,
+ JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_CONTROLABLEACL));
+
+ convertExtension(newTypeSettableAttributesJson,
newTypeSettableAttributes,
+ CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_KEYS);
+
+ result.setNewTypeSettableAttributes(newTypeSettableAttributes);
+ }
+
// handle extensions
convertExtension(json, result, CAP_KEYS);
@@ -494,6 +619,9 @@ public final class JSONConverter {
case CMIS_POLICY:
result = new PolicyTypeDefinitionImpl();
break;
+ case CMIS_ITEM:
+ result = new ItemTypeDefinitionImpl();
+ break;
default:
throw new CmisRuntimeException("Type '" + id + "' does not match a
base type!");
}
@@ -2465,6 +2593,66 @@ public final class JSONConverter {
// -----------------------------------------------------------------
+ /**
+ * Converts bulk update data.
+ */
+ public static JSONObject convert(BulkUpdateObjectIdAndChangeToken oc) {
+ if (oc == null) {
+ return null;
+ }
+
+ JSONObject result = new JSONObject();
+
+ setIfNotNull(JSON_BULK_UPDATE_ID, oc.getId(), result);
+ setIfNotNull(JSON_BULK_UPDATE_NEW_ID, oc.getNewId(), result);
+ setIfNotNull(JSON_BULK_UPDATE_CHANGE_TOKEN, oc.getChangeToken(),
result);
+
+ convertExtension(oc, result);
+
+ return result;
+ }
+
+ /**
+ * Converts bulk update data lists.
+ */
+ public static List<BulkUpdateObjectIdAndChangeToken>
convertBulkUpdate(final List<Object> json) {
+ if (json == null) {
+ return null;
+ }
+
+ List<BulkUpdateObjectIdAndChangeToken> result = new
ArrayList<BulkUpdateObjectIdAndChangeToken>();
+
+ for (Object ocJson : json) {
+ BulkUpdateObjectIdAndChangeToken oc =
convertBulkUpdate(getMap(ocJson));
+ if (oc != null) {
+ result.add(oc);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Converts bulk update data.
+ */
+ public static BulkUpdateObjectIdAndChangeToken convertBulkUpdate(final
Map<String, Object> json) {
+ if (json == null) {
+ return null;
+ }
+
+ String id = getString(json, JSON_BULK_UPDATE_ID);
+ String newId = getString(json, JSON_BULK_UPDATE_NEW_ID);
+ String changeToken = getString(json, JSON_BULK_UPDATE_CHANGE_TOKEN);
+
+ BulkUpdateObjectIdAndChangeTokenImpl result = new
BulkUpdateObjectIdAndChangeTokenImpl(id, newId, changeToken);
+
+ convertExtension(json, result, BULK_UPDATE_KEYS);
+
+ return result;
+ }
+
+ // -----------------------------------------------------------------
+
public static void convertExtension(final ExtensionsData source, final
JSONObject target) {
if (source == null || source.getExtensions() == null) {
return;
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/NewTypeSettableAttributesImpl.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/dataobjects/NewTypeSettableAttributesImpl.java?rev=1418042&r1=1418041&r2=1418042&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/NewTypeSettableAttributesImpl.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/NewTypeSettableAttributesImpl.java
Thu Dec 6 19:42:42 2012
@@ -22,7 +22,7 @@ import java.io.Serializable;
import org.apache.chemistry.opencmis.commons.data.NewTypeSettableAttributes;
-public class NewTypeSettableAttributesImpl implements
NewTypeSettableAttributes, Serializable {
+public class NewTypeSettableAttributesImpl extends ExtensionDataImpl
implements NewTypeSettableAttributes, Serializable {
private static final long serialVersionUID = 1L;
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=1418042&r1=1418041&r2=1418042&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
Thu Dec 6 19:42:42 2012
@@ -80,6 +80,7 @@ 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.CmisNotSupportedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.impl.Constants;
import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
@@ -312,7 +313,7 @@ public final class ObjectService {
// get parameters
String objectId = (String) context.get(CONTEXT_OBJECT_ID);
String typeId = (String) context.get(CONTEXT_OBJECT_TYPE_ID);
- String changeToken = getStringParameter(request,
Constants.PARAM_CHANGE_TOKEN);
+ String changeToken = getStringParameter(request,
Constants.CONTROL_CHANGE_TOKEN);
String token = getStringParameter(request, PARAM_TOKEN);
boolean succinct = getBooleanParameter(request,
Constants.CONTROL_SUCCINCT, false);
@@ -351,7 +352,28 @@ public final class ObjectService {
*/
public static void bulkUpdateProperties(CallContext context, CmisService
service, String repositoryId,
HttpServletRequest request, HttpServletResponse response) throws
Exception {
- // TODO
+
+ throw new CmisNotSupportedException("Not supported!");
+
+ // ControlParser cp = new ControlParser(request);
+ //
+ // List<BulkUpdateObjectIdAndChangeToken> result =
+ // service.bulkUpdateProperties(repositoryId,
+ // objectIdAndChangeToken, properties,
+ // cp.getValues(Constants.CONTROL_ADD_SECONDARY_TYPE),
+ // cp.getValues(Constants.CONTROL_REMOVE_SECONDARY_TYPE), null);
+ //
+ // JSONArray jsonList = new JSONArray();
+ // if (result != null) {
+ // for (BulkUpdateObjectIdAndChangeToken oc : result) {
+ // if (oc != null) {
+ // jsonList.add(JSONConverter.convert(oc));
+ // }
+ // }
+ // }
+ //
+ // response.setStatus(HttpServletResponse.SC_OK);
+ // writeJSON(jsonList, request, response);
}
/**