Revision: 35
Author:
jeanmari...@alfresco.com
Date: Fri Oct 4 13:51:33 2013 UTC
Log: Update OpenCMIS 0.10.0
Better support of CMIS 1.1
http://code.google.com/a/apache-extras.org/p/alfresco-opencmis-extension/source/detail?r=35
Added:
/branches/android/src/main/java/org/alfresco/cmis/client/type/AlfrescoSecondaryType.java
Modified:
/branches/android
/branches/android/pom.xml
/branches/android/src/main/java/org/alfresco/cmis/client/AlfrescoAspects.java
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoAspectsImpl.java
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoDocumentImpl.java
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoDocumentTypeImpl.java
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoFolderImpl.java
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoFolderTypeImpl.java
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoObjectFactoryImpl.java
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoUtils.java
/branches/android/src/main/java/org/alfresco/cmis/client/impl/TransientAlfrescoAspectsImpl.java
/branches/android/src/main/java/org/alfresco/cmis/client/impl/TransientAlfrescoDocumentImpl.java
/branches/android/src/main/java/org/alfresco/cmis/client/impl/TransientAlfrescoFolderImpl.java
=======================================
--- /dev/null
+++
/branches/android/src/main/java/org/alfresco/cmis/client/type/AlfrescoSecondaryType.java
Fri Oct 4 13:51:33 2013 UTC
@@ -0,0 +1,25 @@
+package org.alfresco.cmis.client.type;
+
+import java.util.List;
+
+import org.alfresco.cmis.client.impl.AlfrescoUtils;
+import org.apache.chemistry.opencmis.client.api.Session;
+import
org.apache.chemistry.opencmis.client.runtime.objecttype.SecondaryTypeImpl;
+import
org.apache.chemistry.opencmis.commons.definitions.SecondaryTypeDefinition;
+
+public class AlfrescoSecondaryType extends SecondaryTypeImpl implements
AlfrescoType
+{
+ private static final long serialVersionUID = 3985314017717890607L;
+
+ public AlfrescoSecondaryType(Session session, SecondaryTypeDefinition
typeDefinition)
+ {
+ super(session, typeDefinition);
+ setExtensions(typeDefinition.getExtensions());
+ }
+
+ public List<String> getMandatoryAspects()
+ {
+ return AlfrescoUtils.getMandatoryAspects(this);
+ }
+
+}
=======================================
--- /branches/android/pom.xml Wed May 22 07:52:51 2013 UTC
+++ /branches/android/pom.xml Fri Oct 4 13:51:33 2013 UTC
@@ -20,7 +20,7 @@
<groupId>org.alfresco.cmis.client</groupId>
<artifactId>alfresco-opencmis-extension</artifactId>
<name>Alfresco OpenCMIS Extension</name>
- <version>0.5-ANDROID</version>
+ <version>0.6-ANDROID</version>
<packaging>jar</packaging>
<organization>
@@ -134,8 +134,8 @@
<dependencies>
<dependency>
<groupId>org.apache.chemistry.opencmis</groupId>
- <artifactId>chemistry-opencmis-client-impl</artifactId>
- <version>0.9.0-SNAPSHOT</version>
+ <artifactId>chemistry-opencmis-android-client</artifactId>
+ <version>0.10.0</version>
</dependency>
</dependencies>
</project>
=======================================
---
/branches/android/src/main/java/org/alfresco/cmis/client/AlfrescoAspects.java
Thu Jan 31 13:15:00 2013 UTC
+++
/branches/android/src/main/java/org/alfresco/cmis/client/AlfrescoAspects.java
Fri Oct 4 13:51:33 2013 UTC
@@ -15,16 +15,16 @@
*/
package org.alfresco.cmis.client;
-import java.io.Serializable;
import java.util.Collection;
import java.util.Map;
+import org.apache.chemistry.opencmis.client.api.CmisObject;
import org.apache.chemistry.opencmis.client.api.ObjectType;
/**
* Alfresco aspects interface.
*/
-public interface AlfrescoAspects extends Serializable {
+public interface AlfrescoAspects {
/**
* Returns a type definition with the applied aspects.
@@ -80,16 +80,18 @@
*
* @param id
* the aspect id or ids
+ * @return the changed object (which may be a new object)
*/
- void addAspect(String... id);
+ CmisObject addAspect(String... id);
/**
* Adds one or more aspects to the object.
*
* @param type
* the aspect type or types
+ * @return the changed object (which may be a new object)
*/
- void addAspect(ObjectType... type);
+ CmisObject addAspect(ObjectType... type);
/**
* Adds an aspect and sets aspect properties.
@@ -98,8 +100,9 @@
* the aspect type
* @param properties
* the aspect properties
+ * @return the changed object (which may be a new object)
*/
- void addAspect(ObjectType type, Map<String, ?> properties);
+ CmisObject addAspect(ObjectType type, Map<String, ?> properties);
/**
* Adds aspects and sets aspect properties.
@@ -108,8 +111,9 @@
* the aspect types
* @param properties
* the aspect properties
+ * @return the changed object (which may be a new object)
*/
- void addAspect(ObjectType[] type, Map<String, ?> properties);
+ CmisObject addAspect(ObjectType[] type, Map<String, ?> properties);
/**
* Adds an aspect and sets aspect properties.
@@ -118,8 +122,9 @@
* the aspect type
* @param properties
* the aspect properties
+ * @return the changed object (which may be a new object)
*/
- void addAspect(String id, Map<String, ?> properties);
+ CmisObject addAspect(String id, Map<String, ?> properties);
/**
* Adds aspects and sets aspect properties.
@@ -128,22 +133,25 @@
* the aspect types
* @param properties
* the aspect properties
+ * @return the changed object (which may be a new object)
*/
- void addAspect(String[] id, Map<String, ?> properties);
+ CmisObject addAspect(String[] id, Map<String, ?> properties);
/**
* Removes one or more aspects from the object.
*
* @param id
* the aspect id or ids
+ * @return the changed object (which may be a new object)
*/
- void removeAspect(String... id);
+ CmisObject removeAspect(String... id);
/**
* Removes one or more aspects from the object.
*
* @param id
* the aspect type or types
+ * @return the changed object (which may be a new object)
*/
- void removeAspect(ObjectType... type);
+ CmisObject removeAspect(ObjectType... type);
}
=======================================
---
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoAspectsImpl.java
Thu Jan 31 13:15:00 2013 UTC
+++
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoAspectsImpl.java
Fri Oct 4 13:51:33 2013 UTC
@@ -26,33 +26,49 @@
import org.alfresco.cmis.client.AlfrescoFolder;
import org.apache.chemistry.opencmis.client.api.CmisObject;
import org.apache.chemistry.opencmis.client.api.ObjectType;
+import org.apache.chemistry.opencmis.client.api.Property;
import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
import org.apache.chemistry.opencmis.commons.enums.ExtensionLevel;
public class AlfrescoAspectsImpl implements AlfrescoAspects {
- private Session session;
+ private Session session;
private CmisObject object;
private Map<String, ObjectType> aspectTypes;
-
- private static final long serialVersionUID = 1L;
public AlfrescoAspectsImpl(Session session, CmisObject object) {
this.session = session;
this.object = object;
- List<CmisExtensionElement> alfrescoExtensions = AlfrescoUtils
- .findAlfrescoExtensions(object
- .getExtensions(ExtensionLevel.PROPERTIES));
-
- if (alfrescoExtensions == null) {
- aspectTypes = Collections.emptyMap();
- } else {
+ Property<?> secondaryTypesProp =
object.getProperty(PropertyIds.SECONDARY_OBJECT_TYPE_IDS);
+ if(secondaryTypesProp != null)
+ {
+ // cmis 1.1
+ List<String> secondaryTypes = secondaryTypesProp.getValue();
aspectTypes = new HashMap<String, ObjectType>();
- for (ObjectType type : AlfrescoUtils.getAspectTypes(session,
- alfrescoExtensions)) {
- if (type != null) {
- aspectTypes.put(type.getId(), type);
+ for(String secondaryType : secondaryTypes)
+ {
+ ObjectType aspectType =
session.getTypeDefinition(secondaryType);
+ aspectTypes.put(aspectType.getId(), aspectType);
+ }
+ }
+ else
+ {
+ // cmis 1.0
+ List<CmisExtensionElement> alfrescoExtensions = AlfrescoUtils
+ .findAlfrescoExtensions(object
+ .getExtensions(ExtensionLevel.PROPERTIES));
+
+ if (alfrescoExtensions == null) {
+ aspectTypes = Collections.emptyMap();
+ } else {
+ aspectTypes = new HashMap<String, ObjectType>();
+ for (ObjectType type : AlfrescoUtils.getAspectTypes(session,
+ alfrescoExtensions)) {
+ if (type != null) {
+ aspectTypes.put(type.getId(), type);
+ }
}
}
}
@@ -85,7 +101,7 @@
.findAspect(aspectTypes.values(), propertyId);
}
- public void addAspect(String... id) {
+ public CmisObject addAspect(String... id) {
if (id == null || id.length == 0) {
throw new IllegalArgumentException("Id must be set!");
}
@@ -95,36 +111,48 @@
types[i] = session.getTypeDefinition(id[i]);
}
- addAspect(types);
+ return addAspect(types);
}
- public void addAspect(ObjectType... type) {
+ public CmisObject addAspect(ObjectType... type) {
+ CmisObject ret = object;
+
if (type == null || type.length == 0) {
throw new IllegalArgumentException("Type must be set!");
}
- AlfrescoUtils.updateAspects(session, object.getId(), type, null,
+ String objectId = AlfrescoUtils.updateAspects(session, object, type,
null,
null);
+ if (!object.getId().equals(objectId)) {
+ ret = session.getObject(objectId);
+ }
+ return ret;
}
- public void addAspect(ObjectType type, Map<String, ?> properties) {
- addAspect(new ObjectType[] { type }, properties);
+ public CmisObject addAspect(ObjectType type, Map<String, ?> properties) {
+ return addAspect(new ObjectType[] { type }, properties);
}
- public void addAspect(ObjectType[] type, Map<String, ?> properties) {
+ public CmisObject addAspect(ObjectType[] type, Map<String, ?> properties)
{
+ CmisObject ret = object;
+
if (type == null || type.length == 0) {
throw new IllegalArgumentException("Type must be set!");
}
- AlfrescoUtils.updateAspects(session, object.getId(), type, null,
+ String objectId = AlfrescoUtils.updateAspects(session, object, type,
null,
properties);
+ if (!object.getId().equals(objectId)) {
+ ret = session.getObject(objectId);
+ }
+ return ret;
}
- public void addAspect(String id, Map<String, ?> properties) {
- addAspect(new String[] { id }, properties);
+ public CmisObject addAspect(String id, Map<String, ?> properties) {
+ return addAspect(new String[] { id }, properties);
}
- public void addAspect(String[] id, Map<String, ?> properties) {
+ public CmisObject addAspect(String[] id, Map<String, ?> properties) {
if (id == null || id.length == 0) {
throw new IllegalArgumentException("Id must be set!");
}
@@ -134,10 +162,10 @@
types[i] = session.getTypeDefinition(id[i]);
}
- addAspect(types, properties);
+ return addAspect(types, properties);
}
- public void removeAspect(String... id) {
+ public CmisObject removeAspect(String... id) {
if (id == null || id.length == 0) {
throw new IllegalArgumentException("Id must be set!");
}
@@ -147,15 +175,20 @@
types[i] = session.getTypeDefinition(id[i]);
}
- removeAspect(types);
+ return removeAspect(types);
}
- public void removeAspect(ObjectType... type) {
+ public CmisObject removeAspect(ObjectType... type) {
+ CmisObject ret = object;
if (type == null || type.length == 0) {
throw new IllegalArgumentException("Type must be set!");
}
- AlfrescoUtils.updateAspects(session, object.getId(), null, type,
+ String objectId = AlfrescoUtils.updateAspects(session, object, null,
type,
null);
+ if (!object.getId().equals(objectId)) {
+ ret = session.getObject(objectId);
+ }
+ return ret;
}
}
=======================================
---
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoDocumentImpl.java
Fri Feb 17 17:34:36 2012 UTC
+++
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoDocumentImpl.java
Fri Oct 4 13:51:33 2013 UTC
@@ -21,6 +21,7 @@
import org.alfresco.cmis.client.AlfrescoDocument;
import org.alfresco.cmis.client.AlfrescoDocumentType;
+import org.apache.chemistry.opencmis.client.api.CmisObject;
import org.apache.chemistry.opencmis.client.api.ObjectId;
import org.apache.chemistry.opencmis.client.api.ObjectType;
import org.apache.chemistry.opencmis.client.api.OperationContext;
@@ -120,67 +121,93 @@
}
}
- public void addAspect(String... id) {
+ public CmisObject addAspect(String... id) {
+ CmisObject ret = this;
+
readLock();
try {
- aspects.addAspect(id);
+ ret = aspects.addAspect(id);
} finally {
readUnlock();
}
refresh();
+
+ return ret;
}
- public void addAspect(ObjectType... type) {
+ public CmisObject addAspect(ObjectType... type) {
+ CmisObject ret = this;
+
readLock();
try {
- aspects.addAspect(type);
+ ret = aspects.addAspect(type);
} finally {
readUnlock();
}
refresh();
+
+ return ret;
}
- public void addAspect(ObjectType type, Map<String, ?> properties) {
+ public CmisObject addAspect(ObjectType type, Map<String, ?> properties) {
+ CmisObject ret = this;
+
readLock();
try {
- aspects.addAspect(type, properties);
+ ret = aspects.addAspect(type, properties);
} finally {
readUnlock();
}
refresh();
+
+ return ret;
}
- public void addAspect(ObjectType[] type, Map<String, ?> properties) {
+ public CmisObject addAspect(ObjectType[] type, Map<String, ?> properties)
{
+ CmisObject ret = this;
+
readLock();
try {
- aspects.addAspect(type, properties);
+ ret = aspects.addAspect(type, properties);
} finally {
readUnlock();
}
refresh();
+
+ return ret;
}
- public void addAspect(String id, Map<String, ?> properties) {
+ public CmisObject addAspect(String id, Map<String, ?> properties) {
+ CmisObject ret = this;
+
readLock();
try {
- aspects.addAspect(id, properties);
+ ret = aspects.addAspect(id, properties);
} finally {
readUnlock();
}
refresh();
+
+ return ret;
}
- public void addAspect(String[] id, Map<String, ?> properties) {
+ public CmisObject addAspect(String[] id, Map<String, ?> properties) {
+ CmisObject ret = this;
+
readLock();
try {
- aspects.addAspect(id, properties);
+ ret = aspects.addAspect(id, properties);
} finally {
readUnlock();
}
refresh();
+
+ return ret;
}
- public void removeAspect(String... id) {
+ public CmisObject removeAspect(String... id) {
+ CmisObject ret = this;
+
readLock();
try {
aspects.removeAspect(id);
@@ -188,15 +215,21 @@
readUnlock();
}
refresh();
+
+ return ret;
}
- public void removeAspect(ObjectType... type) {
+ public CmisObject removeAspect(ObjectType... type) {
+ CmisObject ret = this;
+
readLock();
try {
- aspects.removeAspect(type);
+ ret = aspects.removeAspect(type);
} finally {
readUnlock();
}
refresh();
+
+ return ret;
}
}
=======================================
---
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoDocumentTypeImpl.java
Wed May 22 07:52:51 2013 UTC
+++
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoDocumentTypeImpl.java
Fri Oct 4 13:51:33 2013 UTC
@@ -31,6 +31,7 @@
import org.apache.chemistry.opencmis.commons.definitions.TypeMutability;
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed;
+import
org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeMutabilityImpl;
public class AlfrescoDocumentTypeImpl implements AlfrescoDocumentType {
private static final long serialVersionUID = 1L;
@@ -156,8 +157,12 @@
return doc.getType().getDescendants(depth);
}
- @Override
- public TypeMutability getTypeMutability() {
- return doc.getType().getTypeMutability();
+ public TypeMutability getTypeMutability()
+ {
+ TypeMutabilityImpl typeMutability = new TypeMutabilityImpl();
+ typeMutability.setCanCreate(Boolean.FALSE);
+ typeMutability.setCanDelete(Boolean.FALSE);
+ typeMutability.setCanUpdate(Boolean.FALSE);
+ return typeMutability;
}
}
=======================================
---
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoFolderImpl.java
Fri Feb 17 17:34:36 2012 UTC
+++
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoFolderImpl.java
Fri Oct 4 13:51:33 2013 UTC
@@ -19,6 +19,7 @@
import java.util.Map;
import org.alfresco.cmis.client.AlfrescoFolder;
+import org.apache.chemistry.opencmis.client.api.CmisObject;
import org.apache.chemistry.opencmis.client.api.ObjectId;
import org.apache.chemistry.opencmis.client.api.ObjectType;
import org.apache.chemistry.opencmis.client.api.OperationContext;
@@ -123,107 +124,139 @@
}
}
- public void addAspect(String... id)
+ public CmisObject addAspect(String... id)
{
+ CmisObject ret = this;
+
readLock();
try
{
- aspects.addAspect(id);
+ ret = aspects.addAspect(id);
} finally
{
readUnlock();
}
refresh();
+
+ return ret;
}
- public void addAspect(ObjectType... type)
+ public CmisObject addAspect(ObjectType... type)
{
+ CmisObject ret = this;
+
readLock();
try
{
- aspects.addAspect(type);
+ ret = aspects.addAspect(type);
} finally
{
readUnlock();
}
refresh();
+
+ return ret;
}
- public void addAspect(ObjectType type, Map<String, ?> properties)
+ public CmisObject addAspect(ObjectType type, Map<String, ?> properties)
{
+ CmisObject ret = this;
+
readLock();
try
{
- aspects.addAspect(type, properties);
+ ret = aspects.addAspect(type, properties);
} finally
{
readUnlock();
}
refresh();
+
+ return ret;
}
- public void addAspect(ObjectType[] type, Map<String, ?> properties)
+ public CmisObject addAspect(ObjectType[] type, Map<String, ?>
properties)
{
+ CmisObject ret = this;
+
readLock();
try
{
- aspects.addAspect(type, properties);
+ ret = aspects.addAspect(type, properties);
} finally
{
readUnlock();
}
refresh();
+
+ return ret;
}
- public void addAspect(String id, Map<String, ?> properties)
+ public CmisObject addAspect(String id, Map<String, ?> properties)
{
+ CmisObject ret = this;
+
readLock();
try
{
- aspects.addAspect(id, properties);
+ ret = aspects.addAspect(id, properties);
} finally
{
readUnlock();
}
refresh();
+
+ return ret;
}
- public void addAspect(String[] id, Map<String, ?> properties)
+ public CmisObject addAspect(String[] id, Map<String, ?> properties)
{
+ CmisObject ret = this;
+
readLock();
try
{
- aspects.addAspect(id, properties);
+ ret = aspects.addAspect(id, properties);
} finally
{
readUnlock();
}
refresh();
+
+ return ret;
}
- public void removeAspect(String... id)
+ public CmisObject removeAspect(String... id)
{
+ CmisObject ret = this;
+
readLock();
try
{
- aspects.removeAspect(id);
+ ret = aspects.removeAspect(id);
} finally
{
readUnlock();
}
refresh();
+
+ return ret;
}
- public void removeAspect(ObjectType... type)
+ public CmisObject removeAspect(ObjectType... type)
{
+ CmisObject ret = this;
+
readLock();
try
{
- aspects.removeAspect(type);
+ ret = aspects.removeAspect(type);
} finally
{
readUnlock();
}
refresh();
+
+ return ret;
}
}
=======================================
---
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoFolderTypeImpl.java
Wed May 22 07:52:51 2013 UTC
+++
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoFolderTypeImpl.java
Fri Oct 4 13:51:33 2013 UTC
@@ -26,10 +26,10 @@
import org.apache.chemistry.opencmis.client.api.ObjectType;
import org.apache.chemistry.opencmis.client.api.Tree;
import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
-import
org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
import
org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
import org.apache.chemistry.opencmis.commons.definitions.TypeMutability;
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import
org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeMutabilityImpl;
public class AlfrescoFolderTypeImpl implements AlfrescoFolderType
{
@@ -170,9 +170,13 @@
{
return folder.getType().getDescendants(depth);
}
-
- @Override
- public TypeMutability getTypeMutability() {
- return folder.getType().getTypeMutability();
+
+ public TypeMutability getTypeMutability()
+ {
+ TypeMutabilityImpl typeMutability = new TypeMutabilityImpl();
+ typeMutability.setCanCreate(Boolean.FALSE);
+ typeMutability.setCanDelete(Boolean.FALSE);
+ typeMutability.setCanUpdate(Boolean.FALSE);
+ return typeMutability;
}
}
=======================================
---
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoObjectFactoryImpl.java
Wed May 22 07:52:51 2013 UTC
+++
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoObjectFactoryImpl.java
Fri Oct 4 13:51:33 2013 UTC
@@ -23,6 +23,7 @@
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -32,6 +33,7 @@
import org.alfresco.cmis.client.type.AlfrescoFolderType;
import org.alfresco.cmis.client.type.AlfrescoPolicyType;
import org.alfresco.cmis.client.type.AlfrescoRelationshipType;
+import org.alfresco.cmis.client.type.AlfrescoSecondaryType;
import org.apache.chemistry.opencmis.client.api.CmisObject;
import org.apache.chemistry.opencmis.client.api.ObjectType;
import org.apache.chemistry.opencmis.client.api.OperationContext;
@@ -46,12 +48,15 @@
import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
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.definitions.DocumentTypeDefinition;
import
org.apache.chemistry.opencmis.commons.definitions.FolderTypeDefinition;
import
org.apache.chemistry.opencmis.commons.definitions.PolicyTypeDefinition;
import
org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
import
org.apache.chemistry.opencmis.commons.definitions.RelationshipTypeDefinition;
+import
org.apache.chemistry.opencmis.commons.definitions.SecondaryTypeDefinition;
import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
import org.apache.chemistry.opencmis.commons.enums.Updatability;
import
org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
@@ -71,36 +76,47 @@
@Override
public ObjectType convertTypeDefinition(TypeDefinition typeDefinition)
{
- ObjectType ret = null;
+ ObjectType ret = null;
- if (typeDefinition instanceof DocumentTypeDefinition) {
- ret = new AlfrescoDocumentType(this.session,
(DocumentTypeDefinition) typeDefinition);
- } else if (typeDefinition instanceof FolderTypeDefinition) {
- ret = new AlfrescoFolderType(this.session, (FolderTypeDefinition)
typeDefinition);
- } else if (typeDefinition instanceof RelationshipTypeDefinition) {
- ret = new AlfrescoRelationshipType(this.session,
(RelationshipTypeDefinition) typeDefinition);
- } else if (typeDefinition instanceof PolicyTypeDefinition) {
- ret = new AlfrescoPolicyType(this.session, (PolicyTypeDefinition)
typeDefinition);
- } else {
+ if (typeDefinition instanceof DocumentTypeDefinition)
+ {
+ ret = new AlfrescoDocumentType(this.session,
(DocumentTypeDefinition) typeDefinition);
+ }
+ else if (typeDefinition instanceof FolderTypeDefinition)
+ {
+ ret = new AlfrescoFolderType(this.session,
(FolderTypeDefinition) typeDefinition);
+ }
+ else if (typeDefinition instanceof RelationshipTypeDefinition)
+ {
+ ret = new AlfrescoRelationshipType(this.session,
(RelationshipTypeDefinition) typeDefinition);
+ }
+ else if (typeDefinition instanceof PolicyTypeDefinition)
+ {
+ ret = new AlfrescoPolicyType(this.session,
(PolicyTypeDefinition) typeDefinition);
+ }
+ else if (typeDefinition instanceof SecondaryTypeDefinition)
+ {
+ ret = new AlfrescoSecondaryType(this.session,
(SecondaryTypeDefinition) typeDefinition);
+ }
+ else
+ {
throw new CmisRuntimeException("Unknown base type!");
}
- return ret;
+ return ret;
}
-
+
public void initialize(Session session, Map<String, String> parameters)
{
super.initialize(session, parameters);
this.session = session;
}
- public Properties convertProperties(Map<String, ?> properties,
ObjectType type, Collection<SecondaryType> secondaryTypes,
Set<Updatability> updatabilityFilter)
+ public Properties convertProperties(Map<String, ?> properties,
ObjectType type,
+ Collection<SecondaryType> secondaryTypes, Set<Updatability>
updatabilityFilter)
{
// check input
- if (properties == null)
- {
- return null;
- }
+ if (properties == null) { return null; }
// get the object and aspect types
Object typeId = properties.get(PropertyIds.OBJECT_TYPE_ID);
@@ -109,30 +125,33 @@
if (typeId instanceof String)
{
typeIdStr = typeId.toString();
- } else if (typeId instanceof Property<?>)
+ }
+ else if (typeId instanceof Property<?>)
{
Object propValue = ((Property<?>) typeId).getFirstValue();
typeIdStr = (propValue == null ? null : propValue.toString());
}
- if (typeIdStr == null)
- {
- throw new IllegalArgumentException("Type property must be
set!");
- }
+ if (typeIdStr == null) { throw new IllegalArgumentException("Type
property must be set!"); }
+ // CMIS 1.0, secondary types/aspects are in the objectTypeId
ObjectType objectType = null;
List<ObjectType> aspectTypes = new ArrayList<ObjectType>();
+ List<String> secondaryTypesPropValue = new ArrayList<String>();
if (typeIdStr.indexOf(',') == -1)
{
objectType = session.getTypeDefinition(typeIdStr);
- } else
+ }
+ else
{
String[] typeIds = typeIdStr.split(",");
objectType = session.getTypeDefinition(typeIds[0].trim());
for (int i = 1; i < typeIds.length; i++)
{
-
aspectTypes.add(session.getTypeDefinition(typeIds[i].trim()));
+ String secondaryTypeId = typeIds[i].trim();
+ secondaryTypesPropValue.add(secondaryTypeId);
+
aspectTypes.add(session.getTypeDefinition(secondaryTypeId));
}
}
@@ -156,10 +175,12 @@
{
typeProperties.put(id, objectType.getId());
}
- } else if (objectType.getPropertyDefinitions().containsKey(id))
+ }
+ else if (objectType.getPropertyDefinitions().containsKey(id))
{
typeProperties.put(id, value);
- } else
+ }
+ else
{
aspectProperties.put(id, value);
@@ -178,132 +199,174 @@
}
}
- if (!aspectPropertyDefinition.containsKey(id))
- {
- throw new IllegalArgumentException("Property '" + id
- + "' is neither an object type property nor an
aspect property!");
- }
+ if (!aspectPropertyDefinition.containsKey(id)) { throw new
IllegalArgumentException("Property '" + id
+ + "' is neither an object type property nor an
aspect property!"); }
}
}
+
+ if
(session.getRepositoryInfo().getCmisVersion().equals(CmisVersion.CMIS_1_1))
+ {
+ // cmis 1.1 - secondary types
+ typeProperties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS,
secondaryTypesPropValue);
+ }
// prepare type properties
Properties result = super.convertProperties(typeProperties, type,
secondaryTypes, updatabilityFilter);
- // prepare extensions
- List<CmisExtensionElement> alfrescoExtensionList = new
ArrayList<CmisExtensionElement>();
-
- // prepare aspects
- for (ObjectType aspectType : aspectTypes)
+ if
(session.getRepositoryInfo().getCmisVersion().equals(CmisVersion.CMIS_1_0))
{
-
alfrescoExtensionList.add(AlfrescoUtils.createAspectsToAddExtension(aspectType));
- }
+ // prepare extensions
+ List<CmisExtensionElement> alfrescoExtensionList = new
ArrayList<CmisExtensionElement>();
- // prepare aspect properties
- if (!aspectProperties.isEmpty())
- {
- List<CmisExtensionElement> propertrtyExtensionList = new
ArrayList<CmisExtensionElement>();
+ // prepare aspects
+ for (ObjectType aspectType : aspectTypes)
+ {
+
alfrescoExtensionList.add(AlfrescoUtils.createAspectsToAddExtension(aspectType));
+ }
- for (Map.Entry<String, Object> property :
aspectProperties.entrySet())
+ // prepare aspect properties
+ if (!aspectProperties.isEmpty())
{
- PropertyDefinition<?> propDef =
aspectPropertyDefinition.get(property.getKey());
- if (propDef == null)
+ List<CmisExtensionElement> propertrtyExtensionList = new
ArrayList<CmisExtensionElement>();
+
+ for (Map.Entry<String, Object> property :
aspectProperties.entrySet())
{
- throw new IllegalArgumentException("Unknown aspect
property: " + property.getKey());
+ PropertyDefinition<?> propDef =
aspectPropertyDefinition.get(property.getKey());
+ if (propDef == null) { throw new
IllegalArgumentException("Unknown aspect property: "
+ + property.getKey()); }
+
+ CmisExtensionElement element =
AlfrescoUtils.createAspectPropertyExtension(propDef,
+ property.getValue());
+ if (element != null)
+ {
+ propertrtyExtensionList.add(element);
+ }
}
- CmisExtensionElement element =
AlfrescoUtils.createAspectPropertyExtension(propDef,
- property.getValue());
- if (element != null)
- {
- propertrtyExtensionList.add(element);
- }
+
alfrescoExtensionList.add(AlfrescoUtils.createAspectPropertiesExtension(propertrtyExtensionList));
}
-
alfrescoExtensionList.add(AlfrescoUtils.createAspectPropertiesExtension(propertrtyExtensionList));
- }
-
- if (!alfrescoExtensionList.isEmpty())
- {
- result.setExtensions(Collections.singletonList(AlfrescoUtils
- .createSetAspectsExtension(alfrescoExtensionList)));
+ if (!alfrescoExtensionList.isEmpty())
+ {
+
result.setExtensions(Collections.singletonList(AlfrescoUtils
+ .createSetAspectsExtension(alfrescoExtensionList)));
+ }
}
return result;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
- public Map<String, Property<?>> convertProperties(ObjectType
objectType, Collection<SecondaryType> secondaryTypes, Properties
properties)
+ public Map<String, Property<?>> convertProperties(ObjectType
objectType, Collection<SecondaryType> secondaryTypes,
+ Properties properties)
{
- Map<String, Property<?>> result =
super.convertProperties(objectType, secondaryTypes, properties);
- // find the Alfresco extensions
- List<CmisExtensionElement> alfrescoExtensions =
AlfrescoUtils.findAlfrescoExtensions(properties
- .getExtensions());
+ // check input
+ if (objectType == null) { throw new
IllegalArgumentException("Object type must set!"); }
- if (alfrescoExtensions == null)
- {
- // no Alfresco extensions found
- return result;
- }
+ if (objectType.getPropertyDefinitions() == null) { throw new
IllegalArgumentException(
+ "Object type has no property defintions!"); }
- // get the aspect types
- Collection<ObjectType> aspectTypes =
AlfrescoUtils.getAspectTypes(session, alfrescoExtensions);
+ if ((properties == null) || (properties.getProperties() == null))
{ throw new IllegalArgumentException(
+ "Properties must be set!"); }
- for (CmisExtensionElement extension : alfrescoExtensions)
+ // iterate through properties and convert them
+ Map<String, Property<?>> result = new LinkedHashMap<String,
Property<?>>();
+ for (Map.Entry<String, PropertyData<?>> entry :
properties.getProperties().entrySet())
{
- if (!extension.getName().equals("properties"))
+
+ Property<?> apiProperty = null;
+ if (entry.getValue().getId().startsWith("cmis:"))
+ {
+ // find property definition
+ apiProperty = convertProperty(objectType, secondaryTypes,
entry.getValue());
+ }
+ else if (entry.getValue().getId().startsWith("dp:"))
+ {
+ //Resolve Issue when searching using join
+ //ADD Specific alfresco extension to retrieve the
information
+ //NB : add values if necessary to support other aspect
+ //TODO : make it more flexible with a specific
object/manager
+ ObjectType objectTypeAspect =
session.getTypeDefinition("P:dp:restrictable");
+ apiProperty = convertProperty(objectTypeAspect,
secondaryTypes, entry.getValue());
+ }
+
+ if (apiProperty != null)
{
- continue;
+ result.put(entry.getKey(), apiProperty);
}
+ }
+
+ if
(session.getRepositoryInfo().getCmisVersion().equals(CmisVersion.CMIS_1_0))
+ {
+ // find the Alfresco extensions
+ List<CmisExtensionElement> alfrescoExtensions =
AlfrescoUtils.findAlfrescoExtensions(properties
+ .getExtensions());
- for (CmisExtensionElement property : extension.getChildren())
+ if (alfrescoExtensions == null)
{
- String id =
property.getAttributes().get("propertyDefinitionId");
+ // no Alfresco extensions found
+ return result;
+ }
+
+ // get the aspect types
+ Collection<ObjectType> aspectTypes =
AlfrescoUtils.getAspectTypes(session, alfrescoExtensions);
- // find the aspect type
- ObjectType aspectType =
AlfrescoUtils.findAspect(aspectTypes, id);
- if (aspectType == null)
+ for (CmisExtensionElement extension : alfrescoExtensions)
+ {
+ if (!extension.getName().equals("properties"))
{
- throw new IllegalArgumentException("Unknown aspect
property: " + id);
+ continue;
}
- // convert values
- PropertyDefinition propDef =
aspectType.getPropertyDefinitions().get(id);
- List values = new ArrayList();
- try
+ for (CmisExtensionElement property :
extension.getChildren())
{
- for (CmisExtensionElement propertyValues :
property.getChildren())
+ String id =
property.getAttributes().get("propertyDefinitionId");
+
+ // find the aspect type
+ ObjectType aspectType =
AlfrescoUtils.findAspect(aspectTypes, id);
+ if (aspectType == null) { throw new
IllegalArgumentException("Unknown aspect property: " + id); }
+
+ // convert values
+ PropertyDefinition propDef =
aspectType.getPropertyDefinitions().get(id);
+ List values = new ArrayList();
+ try
{
- switch (propDef.getPropertyType())
+ for (CmisExtensionElement propertyValues :
property.getChildren())
{
- case BOOLEAN:
-
values.add(Boolean.parseBoolean(propertyValues.getValue()));
- break;
- case DATETIME:
- GregorianCalendar g = new GregorianCalendar();
- Date d =
DateUtils.parseDate(propertyValues.getValue());
- if (d != null){
- g.setTime(d);
- values.add(g);
+ switch (propDef.getPropertyType())
+ {
+ case BOOLEAN:
+
values.add(Boolean.parseBoolean(propertyValues.getValue()));
+ break;
+ case DATETIME:
+ GregorianCalendar g = new
GregorianCalendar();
+ Date d =
DateUtils.parseDate(propertyValues.getValue());
+ if (d != null)
+ {
+ g.setTime(d);
+ values.add(g);
+ }
+ break;
+ case DECIMAL:
+ values.add(new
BigDecimal(propertyValues.getValue()));
+ break;
+ case INTEGER:
+ values.add(new
BigInteger(propertyValues.getValue()));
+ break;
+ default:
+ values.add(propertyValues.getValue());
}
- break;
- case DECIMAL:
- values.add(new
BigDecimal(propertyValues.getValue()));
- break;
- case INTEGER:
- values.add(new
BigInteger(propertyValues.getValue()));
- break;
- default:
- values.add(propertyValues.getValue());
}
}
- } catch (Exception e)
- {
- throw new IllegalArgumentException("Aspect
conversation exception: " + e.getMessage(), e);
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("Aspect
conversation exception: " + e.getMessage(), e);
+ }
+
+ // add property
+ result.put(id, createProperty(propDef, values));
}
-
- // add property
- result.put(id, createProperty(propDef, values));
}
}
@@ -312,26 +375,23 @@
public CmisObject convertObject(ObjectData objectData,
OperationContext context)
{
- if (objectData == null)
- {
- throw new IllegalArgumentException("Object data is null!");
- }
+ if (objectData == null) { throw new
IllegalArgumentException("Object data is null!"); }
ObjectType type = getTypeFromObjectData(objectData);
/* determine type */
switch (objectData.getBaseTypeId())
{
- case CMIS_DOCUMENT:
- return new AlfrescoDocumentImpl((SessionImpl) this.session,
type, objectData, context);
- case CMIS_FOLDER:
- return new AlfrescoFolderImpl((SessionImpl) this.session,
type, objectData, context);
- case CMIS_POLICY:
- return new PolicyImpl((SessionImpl) this.session, type,
objectData, context);
- case CMIS_RELATIONSHIP:
- return new RelationshipImpl((SessionImpl) this.session, type,
objectData, context);
- default:
- throw new CmisRuntimeException("unsupported type: " +
objectData.getBaseTypeId());
+ case CMIS_DOCUMENT:
+ return new AlfrescoDocumentImpl((SessionImpl)
this.session, type, objectData, context);
+ case CMIS_FOLDER:
+ return new AlfrescoFolderImpl((SessionImpl) this.session,
type, objectData, context);
+ case CMIS_POLICY:
+ return new PolicyImpl((SessionImpl) this.session, type,
objectData, context);
+ case CMIS_RELATIONSHIP:
+ return new RelationshipImpl((SessionImpl) this.session,
type, objectData, context);
+ default:
+ throw new CmisRuntimeException("unsupported type: " +
objectData.getBaseTypeId());
}
}
}
=======================================
---
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoUtils.java
Thu Jan 31 13:15:00 2013 UTC
+++
/branches/android/src/main/java/org/alfresco/cmis/client/impl/AlfrescoUtils.java
Fri Oct 4 13:51:33 2013 UTC
@@ -22,11 +22,14 @@
import java.util.Collections;
import java.util.GregorianCalendar;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.alfresco.cmis.client.impl.utils.DateUtils;
+import org.apache.chemistry.opencmis.client.api.CmisObject;
import org.apache.chemistry.opencmis.client.api.ObjectType;
import org.apache.chemistry.opencmis.client.api.Property;
import org.apache.chemistry.opencmis.client.api.Session;
@@ -34,10 +37,13 @@
import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
import org.apache.chemistry.opencmis.commons.data.Properties;
+import org.apache.chemistry.opencmis.commons.data.PropertyData;
import
org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
import org.apache.chemistry.opencmis.commons.enums.Cardinality;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
import
org.apache.chemistry.opencmis.commons.impl.dataobjects.CmisExtensionElementImpl;
import
org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl;
+import
org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIdImpl;
import org.apache.chemistry.opencmis.commons.spi.Holder;
public class AlfrescoUtils
@@ -222,7 +228,7 @@
if (value instanceof GregorianCalendar)
{
- return DateUtils.format((GregorianCalendar) value);
+ return DateUtils.format((GregorianCalendar) value);
} else if (!(value instanceof String) && !(value instanceof
Number) && !(value instanceof Boolean))
{
throw new IllegalArgumentException("Invalid aspect value!");
@@ -346,92 +352,151 @@
/**
* Adds and removes aspects.
*/
- public static void updateAspects(Session session, String objectId,
ObjectType[] addAspectIds,
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public static String updateAspects(Session session, CmisObject object,
ObjectType[] addAspectIds,
ObjectType[] removeAspectIds, Map<String, ?> properties)
{
+ String objectId = object.getId();
String repId = session.getRepositoryInfo().getId();
Holder<String> objectIdHolder = new Holder<String>(objectId);
Map<String, PropertyDefinition<?>> aspectPropertyDefinition = null;
+ // create properties object
+ Properties cmisProperties = new PropertiesImpl();
+
+ CmisVersion cmisVersion =
session.getRepositoryInfo().getCmisVersion();
- List<CmisExtensionElement> alfrescoExtensionList = new
ArrayList<CmisExtensionElement>();
-
- if (addAspectIds != null)
+ if(cmisVersion.equals(CmisVersion.CMIS_1_1))
{
- aspectPropertyDefinition = new HashMap<String,
PropertyDefinition<?>>();
- for (ObjectType type : addAspectIds)
- {
- if (type != null)
- {
-
alfrescoExtensionList.add(AlfrescoUtils.createAspectsToAddExtension(type));
+ // cmis 1.1
+ Property<?> secondaryTypesProp =
object.getProperty(PropertyIds.SECONDARY_OBJECT_TYPE_IDS);
+ List currentSecondaryTypes = (List)secondaryTypesProp.getValue();
+ Set<String> currentSecondaryTypesSet = new
HashSet<String>(currentSecondaryTypes);
- if (type.getPropertyDefinitions() != null)
- {
-
aspectPropertyDefinition.putAll(type.getPropertyDefinitions());
- }
- }
- }
- }
+ if (addAspectIds != null)
+ {
+ Set<String> addAspects = new HashSet<String>();
+ for(ObjectType type : addAspectIds)
+ {
+ addAspects.add(type.getId());
+ }
+ currentSecondaryTypesSet.addAll(addAspects);
+ }
- if (removeAspectIds != null)
- {
- for (ObjectType type : removeAspectIds)
- {
- if (type != null)
- {
-
alfrescoExtensionList.add(AlfrescoUtils.createAspectsToRemoveExtension(type));
- }
- }
- }
+ if (removeAspectIds != null)
+ {
+ Set<String> removeAspects = new HashSet<String>();
+ for(ObjectType type : removeAspectIds)
+ {
+ removeAspects.add(type.getId());
+ }
+ currentSecondaryTypesSet.removeAll(removeAspects);
+ }
+
+ List<String> secondaryTypesToSet = new ArrayList<String>();
+ for(String secondaryType : currentSecondaryTypesSet)
+ {
+ secondaryTypesToSet.add(secondaryType);
+ }
+
+ if(secondaryTypesToSet.isEmpty())
+ {
+ // nothing to do
+ return objectId;
+ }
- if (alfrescoExtensionList.isEmpty())
- {
- return;
+ Collection<PropertyData<?>> props = new
ArrayList<PropertyData<?>>(1);
+ PropertyData<?> updatedSecondaryTypesProp = new
PropertyIdImpl(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypesToSet);
+ props.add(updatedSecondaryTypesProp);
+ cmisProperties = new PropertiesImpl(props);
+ session.getBinding().getObjectService().updateProperties(repId,
objectIdHolder, null, cmisProperties, null);
}
-
- // add property values
- if (addAspectIds != null && properties != null
&& !properties.isEmpty())
+ else if(cmisVersion.equals(CmisVersion.CMIS_1_0))
{
- List<CmisExtensionElement> aspectProperties = new
ArrayList<CmisExtensionElement>(properties.size());
-
- for (Map.Entry<String, ?> property : properties.entrySet())
- {
- if ((property == null) || (property.getKey() == null))
- {
- continue;
- }
-
- String id = property.getKey();
- Object value = property.getValue();
-
- if (!aspectPropertyDefinition.containsKey(id))
- {
- throw new IllegalArgumentException("Property '" + id
+ "' is not an aspect property!");
- }
-
-
aspectProperties.add(createAspectPropertyExtension(aspectPropertyDefinition.get(id),
value));
- }
+ // cmis 1.0
+ List<CmisExtensionElement> alfrescoExtensionList = new
ArrayList<CmisExtensionElement>();
+
+ if (addAspectIds != null)
+ {
+ aspectPropertyDefinition = new HashMap<String,
PropertyDefinition<?>>();
+ for (ObjectType type : addAspectIds)
+ {
+ if (type != null)
+ {
+
alfrescoExtensionList.add(AlfrescoUtils.createAspectsToAddExtension(type));
+
+ if (type.getPropertyDefinitions() != null)
+ {
+
aspectPropertyDefinition.putAll(type.getPropertyDefinitions());
+ }
+ }
+ }
+ }
+
+ if (removeAspectIds != null)
+ {
+ for (ObjectType type : removeAspectIds)
+ {
+ if (type != null)
+ {
+
alfrescoExtensionList.add(AlfrescoUtils.createAspectsToRemoveExtension(type));
+ }
+ }
+ }
+
+ if (alfrescoExtensionList.isEmpty())
+ {
+ return objectId;
+ }
+
+ // add property values
+ if (addAspectIds != null && properties != null
&& !properties.isEmpty())
+ {
+ List<CmisExtensionElement> aspectProperties = new
ArrayList<CmisExtensionElement>(properties.size());
+
+ for (Map.Entry<String, ?> property : properties.entrySet())
+ {
+ if ((property == null) || (property.getKey() == null))
+ {
+ continue;
+ }
+
+ String id = property.getKey();
+ Object value = property.getValue();
+
+ if (!aspectPropertyDefinition.containsKey(id))
+ {
+ throw new IllegalArgumentException("Property '" + id
+ "' is not an aspect property!");
+ }
+
+
aspectProperties.add(createAspectPropertyExtension(aspectPropertyDefinition.get(id),
value));
+ }
+
+
alfrescoExtensionList.add(AlfrescoUtils.createAspectPropertiesExtension(aspectProperties));
+ }
-
alfrescoExtensionList.add(AlfrescoUtils.createAspectPropertiesExtension(aspectProperties));
+ cmisProperties = new PropertiesImpl();
+
cmisProperties.setExtensions(Collections.singletonList(AlfrescoUtils
+ .createSetAspectsExtension(alfrescoExtensionList)));
}
-
- // create properties object
- Properties cmisProperties = new PropertiesImpl();
-
cmisProperties.setExtensions(Collections.singletonList(AlfrescoUtils
- .createSetAspectsExtension(alfrescoExtensionList)));
session.getBinding().getObjectService().updateProperties(repId,
objectIdHolder, null, cmisProperties, null);
+
+ return objectIdHolder.getValue();
}
private static CmisExtensionElement
getExtension(List<CmisExtensionElement> extensions, String namespace,
String name)
{
CmisExtensionElement ret = null;
- for(CmisExtensionElement elem : extensions)
+ if (extensions != null)
{
- if(elem.getNamespace().equals(namespace) &&
elem.getName().equals(name))
- {
- ret = elem;
- }
+ for(CmisExtensionElement elem : extensions)
+ {
+ if(elem.getNamespace().equals(namespace) &&
elem.getName().equals(name))
+ {
+ ret = elem;
+ }
+ }
}
return ret;
=======================================
---
/branches/android/src/main/java/org/alfresco/cmis/client/impl/TransientAlfrescoAspectsImpl.java
Fri Feb 17 17:34:36 2012 UTC
+++
/branches/android/src/main/java/org/alfresco/cmis/client/impl/TransientAlfrescoAspectsImpl.java
Fri Oct 4 13:51:33 2013 UTC
@@ -106,7 +106,7 @@
return AlfrescoUtils.findAspect(getAspects(), propertyId);
}
- public void addAspect(String... id) {
+ public CmisObject addAspect(String... id) {
if (id == null || id.length == 0) {
throw new IllegalArgumentException("Id must be set!");
}
@@ -116,10 +116,10 @@
types[i] = session.getTypeDefinition(id[i]);
}
- addAspect(types);
+ return addAspect(types);
}
- public void addAspect(ObjectType... type) {
+ public CmisObject addAspect(ObjectType... type) {
if (type == null || type.length == 0) {
throw new IllegalArgumentException("Type must be set!");
}
@@ -130,6 +130,8 @@
removeAspectTypes.remove(t.getId());
}
}
+
+ return object;
}
public void setPropertyValues(TransientCmisObject object,
@@ -143,23 +145,23 @@
}
}
- public void addAspect(ObjectType type, Map<String, ?> properties) {
- addAspect(type);
+ public CmisObject addAspect(ObjectType type, Map<String, ?> properties) {
+ return addAspect(type);
}
- public void addAspect(ObjectType[] type, Map<String, ?> properties) {
- addAspect(type);
+ public CmisObject addAspect(ObjectType[] type, Map<String, ?> properties)
{
+ return addAspect(type);
}
- public void addAspect(String id, Map<String, ?> properties) {
- addAspect(id);
+ public CmisObject addAspect(String id, Map<String, ?> properties) {
+ return addAspect(id);
}
- public void addAspect(String[] id, Map<String, ?> properties) {
- addAspect(id);
+ public CmisObject addAspect(String[] id, Map<String, ?> properties) {
+ return addAspect(id);
}
- public void removeAspect(String... id) {
+ public CmisObject removeAspect(String... id) {
if (id == null || id.length == 0) {
throw new IllegalArgumentException("Id must be set!");
}
@@ -169,10 +171,10 @@
types[i] = session.getTypeDefinition(id[i]);
}
- removeAspect(types);
+ return removeAspect(types);
}
- public void removeAspect(ObjectType... type) {
+ public CmisObject removeAspect(ObjectType... type) {
if (type == null || type.length == 0) {
throw new IllegalArgumentException("Type must be set!");
}
@@ -183,6 +185,7 @@
removeAspectTypes.put(t.getId(), t);
}
}
+ return object;
}
public void save() {
@@ -190,7 +193,7 @@
return;
}
- AlfrescoUtils.updateAspects(session, object.getId(),
+ AlfrescoUtils.updateAspects(session, object,
addAspectTypes.values().toArray(new ObjectType[0]),
removeAspectTypes.values().toArray(new ObjectType[0]), null);
}
=======================================
---
/branches/android/src/main/java/org/alfresco/cmis/client/impl/TransientAlfrescoDocumentImpl.java
Fri Feb 17 17:34:36 2012 UTC
+++
/branches/android/src/main/java/org/alfresco/cmis/client/impl/TransientAlfrescoDocumentImpl.java
Fri Oct 4 13:51:33 2013 UTC
@@ -94,40 +94,44 @@
return aspects.findAspect(propertyId);
}
- public void addAspect(String... id) {
- aspects.addAspect(id);
+ public CmisObject addAspect(String... id) {
+ return aspects.addAspect(id);
}
- public void addAspect(ObjectType... type) {
- aspects.addAspect(type);
+ public CmisObject addAspect(ObjectType... type) {
+ return aspects.addAspect(type);
}
- public void addAspect(ObjectType type, Map<String, ?> properties) {
- aspects.addAspect(type);
+ public CmisObject addAspect(ObjectType type, Map<String, ?> properties) {
+ CmisObject cmisObject = aspects.addAspect(type);
aspects.setPropertyValues(this, properties);
+ return cmisObject;
}
- public void addAspect(ObjectType[] type, Map<String, ?> properties) {
- aspects.addAspect(type);
+ public CmisObject addAspect(ObjectType[] type, Map<String, ?> properties)
{
+ CmisObject cmisObject = aspects.addAspect(type);
aspects.setPropertyValues(this, properties);
+ return cmisObject;
}
- public void addAspect(String id, Map<String, ?> properties) {
- aspects.addAspect(id);
+ public CmisObject addAspect(String id, Map<String, ?> properties) {
+ CmisObject cmisObject = aspects.addAspect(id);
aspects.setPropertyValues(this, properties);
+ return cmisObject;
}
- public void addAspect(String[] id, Map<String, ?> properties) {
- aspects.addAspect(id);
+ public CmisObject addAspect(String[] id, Map<String, ?> properties) {
+ CmisObject cmisObject = aspects.addAspect(id);
aspects.setPropertyValues(this, properties);
+ return cmisObject;
}
- public void removeAspect(String... id) {
- aspects.removeAspect(id);
+ public CmisObject removeAspect(String... id) {
+ return aspects.removeAspect(id);
}
- public void removeAspect(ObjectType... type) {
- aspects.removeAspect(type);
+ public CmisObject removeAspect(ObjectType... type) {
+ return aspects.removeAspect(type);
}
@Override
=======================================
---
/branches/android/src/main/java/org/alfresco/cmis/client/impl/TransientAlfrescoFolderImpl.java
Fri Feb 17 17:34:36 2012 UTC
+++
/branches/android/src/main/java/org/alfresco/cmis/client/impl/TransientAlfrescoFolderImpl.java
Fri Oct 4 13:51:33 2013 UTC
@@ -100,48 +100,52 @@
return aspects.findAspect(propertyId);
}
- public void addAspect(String... id)
+ public CmisObject addAspect(String... id)
{
- aspects.addAspect(id);
+ return aspects.addAspect(id);
}
- public void addAspect(ObjectType... type)
+ public CmisObject addAspect(ObjectType... type)
{
- aspects.addAspect(type);
+ return aspects.addAspect(type);
}
- public void removeAspect(String... id)
+ public CmisObject removeAspect(String... id)
{
- aspects.removeAspect(id);
+ return aspects.removeAspect(id);
}
- public void addAspect(ObjectType type, Map<String, ?> properties)
+ public CmisObject addAspect(ObjectType type, Map<String, ?> properties)
{
- aspects.addAspect(type);
+ CmisObject ret = aspects.addAspect(type);
aspects.setPropertyValues(this, properties);
+ return ret;
}
- public void addAspect(ObjectType[] type, Map<String, ?> properties)
+ public CmisObject addAspect(ObjectType[] type, Map<String, ?>
properties)
{
- aspects.addAspect(type);
+ CmisObject ret = aspects.addAspect(type);
aspects.setPropertyValues(this, properties);
+ return ret;
}
- public void addAspect(String id, Map<String, ?> properties)
+ public CmisObject addAspect(String id, Map<String, ?> properties)
{
- aspects.addAspect(id);
+ CmisObject ret = aspects.addAspect(id);
aspects.setPropertyValues(this, properties);
+ return ret;
}
- public void addAspect(String[] id, Map<String, ?> properties)
+ public CmisObject addAspect(String[] id, Map<String, ?> properties)
{
- aspects.addAspect(id);
+ CmisObject ret = aspects.addAspect(id);
aspects.setPropertyValues(this, properties);
+ return ret;
}
- public void removeAspect(ObjectType... type)
+ public CmisObject removeAspect(ObjectType... type)
{
- aspects.removeAspect(type);
+ return aspects.removeAspect(type);
}
@Override