Author: fmui
Date: Fri Jan 4 11:48:31 2013
New Revision: 1428811
URL: http://svn.apache.org/viewvc?rev=1428811&view=rev
Log:
CMIS 1.1: secondary types improvements
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ObjectFactory.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/OperationContext.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractCmisObject.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractTransientCmisObject.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/OperationContextImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.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-api/src/main/java/org/apache/chemistry/opencmis/client/api/ObjectFactory.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ObjectFactory.java?rev=1428811&r1=1428810&r2=1428811&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ObjectFactory.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ObjectFactory.java
Fri Jan 4 11:48:31 2013
@@ -19,6 +19,7 @@
package org.apache.chemistry.opencmis.client.api;
import java.io.InputStream;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -108,9 +109,11 @@ public interface ObjectFactory {
<T> Property<T> createProperty(PropertyDefinition<T> type, List<T> values);
- Map<String, Property<?>> convertProperties(ObjectType objectType,
Properties properties);
+ Map<String, Property<?>> convertProperties(ObjectType objectType,
Collection<SecondaryType> secondaryTypes,
+ Properties properties);
- Properties convertProperties(Map<String, ?> properties, ObjectType type,
Set<Updatability> updatabilityFilter);
+ Properties convertProperties(Map<String, ?> properties, ObjectType type,
Collection<SecondaryType> secondaryTypes,
+ Set<Updatability> updatabilityFilter);
List<PropertyData<?>> convertQueryProperties(Properties properties);
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/OperationContext.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/OperationContext.java?rev=1428811&r1=1428810&r2=1428811&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/OperationContext.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/OperationContext.java
Fri Jan 4 11:48:31 2013
@@ -59,6 +59,16 @@ public interface OperationContext extend
String getFilterString();
/**
+ * Sets if secondary type properties should be loaded.
+ */
+ void setLoadSecondaryTypeProperties(boolean load);
+
+ /**
+ * Returns is secondary type properties should be loaded.
+ */
+ boolean loadSecondaryTypeProperties();
+
+ /**
* Returns if allowable actions should returned.
*/
boolean isIncludeAllowableActions();
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractCmisObject.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractCmisObject.java?rev=1428811&r1=1428810&r2=1428811&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractCmisObject.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractCmisObject.java
Fri Jan 4 11:48:31 2013
@@ -105,9 +105,31 @@ public abstract class AbstractCmisObject
ObjectFactory of = getObjectFactory();
if (objectData != null) {
+
// handle properties
if (objectData.getProperties() != null) {
- this.properties = of.convertProperties(objectType,
objectData.getProperties());
+
+ // get secondary types
+ if (objectData.getProperties().getProperties() != null
+ && objectData.getProperties().getProperties()
+
.containsKey(PropertyIds.SECONDARY_OBJECT_TYPE_IDS)) {
+ @SuppressWarnings("unchecked")
+ List<String> stids = (List<String>)
objectData.getProperties().getProperties()
+
.get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS).getValues();
+ if (stids != null && stids.size() > 0) {
+ secondaryTypes = new ArrayList<SecondaryType>();
+ for (String stid : stids) {
+ if (stid != null) {
+ ObjectType type =
session.getTypeDefinition(stid);
+ if (type instanceof SecondaryType) {
+ secondaryTypes.add((SecondaryType) type);
+ }
+ }
+ }
+ }
+ }
+
+ this.properties = of.convertProperties(objectType,
secondaryTypes, objectData.getProperties());
extensions.put(ExtensionLevel.PROPERTIES,
objectData.getProperties().getExtensions());
}
@@ -154,23 +176,6 @@ public abstract class AbstractCmisObject
}
}
- // get secondary types
- if (properties.containsKey(PropertyIds.SECONDARY_OBJECT_TYPE_IDS))
{
- @SuppressWarnings("unchecked")
- List<String> stids = (List<String>)
properties.get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS).getValues();
- if (stids != null && stids.size() > 0) {
- secondaryTypes = new ArrayList<SecondaryType>();
- for (String stid : stids) {
- if (stid != null) {
- ObjectType type = session.getTypeDefinition(stid);
- if (type instanceof SecondaryType) {
- secondaryTypes.add((SecondaryType) type);
- }
- }
- }
- }
- }
-
extensions.put(ExtensionLevel.OBJECT, objectData.getExtensions());
}
@@ -335,8 +340,12 @@ public abstract class AbstractCmisObject
}
// it's time to update
-
getBinding().getObjectService().updateProperties(getRepositoryId(),
objectIdHolder, changeTokenHolder,
- getObjectFactory().convertProperties(properties,
this.objectType, updatebility), null);
+ getBinding().getObjectService().updateProperties(
+ getRepositoryId(),
+ objectIdHolder,
+ changeTokenHolder,
+ getObjectFactory()
+ .convertProperties(properties, this.objectType,
this.secondaryTypes, updatebility), null);
newObjectId = objectIdHolder.getValue();
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractTransientCmisObject.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractTransientCmisObject.java?rev=1428811&r1=1428810&r2=1428811&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractTransientCmisObject.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractTransientCmisObject.java
Fri Jan 4 11:48:31 2013
@@ -473,7 +473,8 @@ public abstract class AbstractTransientC
}
// convert properties
- Properties result = getObjectFactory().convertProperties(properties,
getType(), updatebility);
+ Properties result = getObjectFactory().convertProperties(properties,
getType(), getSecondaryTypes(),
+ updatebility);
// extensions
List<CmisExtensionElement> extensions =
ouputExtensions.get(ExtensionLevel.PROPERTIES);
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java?rev=1428811&r1=1428810&r2=1428811&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
Fri Jan 4 11:48:31 2013
@@ -271,9 +271,9 @@ public class DocumentImpl extends Abstra
updatebility.add(Updatability.WHENCHECKEDOUT);
getBinding().getVersioningService().checkIn(getRepositoryId(),
objectIdHolder, major,
- of.convertProperties(properties, getType(), updatebility),
of.convertContentStream(contentStream),
- checkinComment, of.convertPolicies(policies),
of.convertAces(addAces), of.convertAces(removeAces),
- null);
+ of.convertProperties(properties, getType(),
getSecondaryTypes(), updatebility),
+ of.convertContentStream(contentStream), checkinComment,
of.convertPolicies(policies),
+ of.convertAces(addAces), of.convertAces(removeAces), null);
newObjectId = objectIdHolder.getValue();
} finally {
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/OperationContextImpl.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/OperationContextImpl.java?rev=1428811&r1=1428810&r2=1428811&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/OperationContextImpl.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/OperationContextImpl.java
Fri Jan 4 11:48:31 2013
@@ -38,6 +38,7 @@ public class OperationContextImpl implem
private static final long serialVersionUID = 1L;
private TreeSet<String> filter;
+ private boolean loadSecondaryTypeProperties;
private boolean includeAcls;
private boolean includeAllowableActions;
private boolean includePolicies;
@@ -54,6 +55,7 @@ public class OperationContextImpl implem
*/
public OperationContextImpl() {
setFilter(null);
+ setLoadSecondaryTypeProperties(false);
setIncludeAcls(false);
setIncludeAllowableActions(true);
setIncludePolicies(false);
@@ -72,6 +74,7 @@ public class OperationContextImpl implem
*/
public OperationContextImpl(OperationContext source) {
setFilter(source.getFilter());
+ setLoadSecondaryTypeProperties(source.loadSecondaryTypeProperties());
setIncludeAcls(source.isIncludeAcls());
setIncludeAllowableActions(source.isIncludeAllowableActions());
setIncludePolicies(source.isIncludePolicies());
@@ -177,6 +180,9 @@ public class OperationContextImpl implem
this.filter.add(PropertyIds.OBJECT_ID);
this.filter.add(PropertyIds.BASE_TYPE_ID);
this.filter.add(PropertyIds.OBJECT_TYPE_ID);
+ if (loadSecondaryTypeProperties) {
+ this.filter.add(PropertyIds.SECONDARY_OBJECT_TYPE_IDS);
+ }
StringBuilder sb = new StringBuilder();
@@ -191,6 +197,14 @@ public class OperationContextImpl implem
return sb.toString();
}
+ public void setLoadSecondaryTypeProperties(boolean load) {
+ this.loadSecondaryTypeProperties = load;
+ }
+
+ public boolean loadSecondaryTypeProperties() {
+ return loadSecondaryTypeProperties;
+ }
+
public boolean isIncludeAcls() {
return includeAcls;
}
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java?rev=1428811&r1=1428810&r2=1428811&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
Fri Jan 4 11:48:31 2013
@@ -42,6 +42,7 @@ import org.apache.chemistry.opencmis.cli
import org.apache.chemistry.opencmis.client.api.QueryResult;
import org.apache.chemistry.opencmis.client.api.QueryStatement;
import org.apache.chemistry.opencmis.client.api.Relationship;
+import org.apache.chemistry.opencmis.client.api.SecondaryType;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.Tree;
import org.apache.chemistry.opencmis.client.runtime.cache.Cache;
@@ -753,7 +754,7 @@ public class SessionImpl implements Sess
String newId = getBinding().getObjectService().createDocument(
getRepositoryId(),
- objectFactory.convertProperties(properties, null,
+ objectFactory.convertProperties(properties, null, null,
(versioningState == VersioningState.CHECKEDOUT ?
CREATE_AND_CHECKOUT_UPDATABILITY
: CREATE_UPDATABILITY)), (folderId == null ?
null : folderId.getId()),
objectFactory.convertContentStream(contentStream),
versioningState,
@@ -775,11 +776,14 @@ public class SessionImpl implements Sess
// get the type of the source document
ObjectType type = null;
+ List<SecondaryType> secondaryTypes = null;
if (source instanceof CmisObject) {
type = ((CmisObject) source).getType();
+ secondaryTypes = ((CmisObject) source).getSecondaryTypes();
} else {
CmisObject sourceObj = getObject(source);
type = sourceObj.getType();
+ secondaryTypes = sourceObj.getSecondaryTypes();
}
if (type.getBaseTypeId() != BaseTypeId.CMIS_DOCUMENT) {
@@ -789,7 +793,7 @@ public class SessionImpl implements Sess
String newId =
getBinding().getObjectService().createDocumentFromSource(
getRepositoryId(),
source.getId(),
- objectFactory.convertProperties(properties, type,
+ objectFactory.convertProperties(properties, type,
secondaryTypes,
(versioningState == VersioningState.CHECKEDOUT ?
CREATE_AND_CHECKOUT_UPDATABILITY
: CREATE_UPDATABILITY)), (folderId == null ?
null : folderId.getId()), versioningState,
objectFactory.convertPolicies(policies),
objectFactory.convertAces(addAces),
@@ -812,7 +816,7 @@ public class SessionImpl implements Sess
}
String newId =
getBinding().getObjectService().createFolder(getRepositoryId(),
- objectFactory.convertProperties(properties, null,
CREATE_UPDATABILITY), folderId.getId(),
+ objectFactory.convertProperties(properties, null, null,
CREATE_UPDATABILITY), folderId.getId(),
objectFactory.convertPolicies(policies),
objectFactory.convertAces(addAces),
objectFactory.convertAces(removeAces), null);
@@ -830,7 +834,7 @@ public class SessionImpl implements Sess
}
String newId =
getBinding().getObjectService().createPolicy(getRepositoryId(),
- objectFactory.convertProperties(properties, null,
CREATE_UPDATABILITY),
+ objectFactory.convertProperties(properties, null, null,
CREATE_UPDATABILITY),
(folderId == null ? null : folderId.getId()),
objectFactory.convertPolicies(policies),
objectFactory.convertAces(addAces),
objectFactory.convertAces(removeAces), null);
@@ -848,7 +852,7 @@ public class SessionImpl implements Sess
}
String newId =
getBinding().getObjectService().createItem(getRepositoryId(),
- objectFactory.convertProperties(properties, null,
CREATE_UPDATABILITY),
+ objectFactory.convertProperties(properties, null, null,
CREATE_UPDATABILITY),
(folderId == null ? null : folderId.getId()),
objectFactory.convertPolicies(policies),
objectFactory.convertAces(addAces),
objectFactory.convertAces(removeAces), null);
@@ -866,7 +870,7 @@ public class SessionImpl implements Sess
}
String newId =
getBinding().getObjectService().createRelationship(getRepositoryId(),
- objectFactory.convertProperties(properties, null,
CREATE_UPDATABILITY),
+ objectFactory.convertProperties(properties, null, null,
CREATE_UPDATABILITY),
objectFactory.convertPolicies(policies),
objectFactory.convertAces(addAces),
objectFactory.convertAces(removeAces), null);
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java?rev=1428811&r1=1428810&r2=1428811&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java
Fri Jan 4 11:48:31 2013
@@ -23,6 +23,7 @@ import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar;
@@ -42,6 +43,7 @@ import org.apache.chemistry.opencmis.cli
import org.apache.chemistry.opencmis.client.api.Property;
import org.apache.chemistry.opencmis.client.api.QueryResult;
import org.apache.chemistry.opencmis.client.api.Rendition;
+import org.apache.chemistry.opencmis.client.api.SecondaryType;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.runtime.ChangeEventImpl;
import org.apache.chemistry.opencmis.client.runtime.ChangeEventsImpl;
@@ -252,16 +254,32 @@ public class ObjectFactoryImpl implement
}
@SuppressWarnings("unchecked")
- protected <T> Property<T> convertProperty(ObjectType objectType,
PropertyData<T> pd) {
+ protected <T> Property<T> convertProperty(ObjectType objectType,
Collection<SecondaryType> secondaryTypes,
+ PropertyData<T> pd) {
PropertyDefinition<T> definition = (PropertyDefinition<T>)
objectType.getPropertyDefinitions().get(pd.getId());
+
+ // search secondary types
+ if (definition == null && secondaryTypes != null) {
+ for (SecondaryType secondaryType : secondaryTypes) {
+ if (secondaryType != null &&
secondaryType.getPropertyDefinitions() != null) {
+ definition = (PropertyDefinition<T>)
secondaryType.getPropertyDefinitions().get(pd.getId());
+ if (definition != null) {
+ break;
+ }
+ }
+ }
+ }
+
if (definition == null) {
// property without definition
throw new CmisRuntimeException("Property '" + pd.getId() + "'
doesn't exist!");
}
+
return createProperty(definition, pd.getValues());
}
- public Map<String, Property<?>> convertProperties(ObjectType objectType,
Properties properties) {
+ public Map<String, Property<?>> convertProperties(ObjectType objectType,
Collection<SecondaryType> secondaryTypes,
+ Properties properties) {
// check input
if (objectType == null) {
throw new IllegalArgumentException("Object type must set!");
@@ -279,7 +297,7 @@ public class ObjectFactoryImpl implement
Map<String, Property<?>> result = new LinkedHashMap<String,
Property<?>>();
for (Map.Entry<String, PropertyData<?>> entry :
properties.getProperties().entrySet()) {
// find property definition
- Property<?> apiProperty = convertProperty(objectType,
entry.getValue());
+ Property<?> apiProperty = convertProperty(objectType,
secondaryTypes, entry.getValue());
result.put(entry.getKey(), apiProperty);
}
@@ -287,7 +305,8 @@ public class ObjectFactoryImpl implement
}
@SuppressWarnings("unchecked")
- public Properties convertProperties(Map<String, ?> properties, ObjectType
type, Set<Updatability> updatabilityFilter) {
+ public Properties convertProperties(Map<String, ?> properties, ObjectType
type,
+ Collection<SecondaryType> secondaryTypes, Set<Updatability>
updatabilityFilter) {
// check input
if (properties == null) {
return null;
@@ -303,6 +322,33 @@ public class ObjectFactoryImpl implement
type = session.getTypeDefinition(typeId.toString());
}
+ // get secondary types
+ Collection<SecondaryType> allSecondaryTypes = null;
+ Object secondaryTypeIds =
properties.get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS);
+ if (secondaryTypeIds instanceof List) {
+ allSecondaryTypes = new ArrayList<SecondaryType>();
+
+ for (Object secondaryTypeId : (List<?>) secondaryTypeIds) {
+ if (!(secondaryTypeId instanceof String)) {
+ throw new IllegalArgumentException("Secondary types
property contains an invalid entry: "
+ + secondaryTypeId);
+ }
+
+ ObjectType secondaryType =
session.getTypeDefinition(secondaryTypeId.toString());
+ if (!(secondaryType instanceof SecondaryType)) {
+ throw new IllegalArgumentException(
+ "Secondary types property contains a type that is
not a secondary type: "
+ + secondaryType.getId());
+ }
+
+ allSecondaryTypes.add((SecondaryType) secondaryType);
+ }
+ }
+
+ if (secondaryTypes != null && allSecondaryTypes == null) {
+ allSecondaryTypes = secondaryTypes;
+ }
+
// some preparation
BindingsObjectFactory bof = getBindingsObjectFactory();
List<PropertyData<?>> propertyList = new ArrayList<PropertyData<?>>();
@@ -326,8 +372,21 @@ public class ObjectFactoryImpl implement
// get the property definition
PropertyDefinition<?> definition =
type.getPropertyDefinitions().get(id);
+
+ if (definition == null && allSecondaryTypes != null) {
+ for (SecondaryType secondaryType : allSecondaryTypes) {
+ if (secondaryType != null &&
secondaryType.getPropertyDefinitions() != null) {
+ definition = (PropertyDefinition<?>)
secondaryType.getPropertyDefinitions().get(id);
+ if (definition != null) {
+ break;
+ }
+ }
+ }
+ }
+
if (definition == null) {
- throw new IllegalArgumentException("Property '" + id + "' is
not valid for this type!");
+ throw new IllegalArgumentException("Property '" + id
+ + "' is not valid for this type or one of the
secondary types!");
}
// check updatability
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=1428811&r1=1428810&r2=1428811&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
Fri Jan 4 11:48:31 2013
@@ -1093,7 +1093,10 @@ public final class JSONConverter {
for (PropertyData<?> property : properties.getPropertyList()) {
PropertyDefinition<?> propDef = null;
- if (type != null) {
+ if (typeCache != null) {
+ propDef = typeCache.getPropertyDefinition(property.getId());
+ }
+ if (propDef == null && type != null) {
propDef = type.getPropertyDefinitions().get(property.getId());
}
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=1428811&r1=1428810&r2=1428811&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
Fri Jan 4 11:48:31 2013
@@ -306,6 +306,7 @@ public final class BrowserBindingUtils {
}
}
}
+ break;
}
i++;
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=1428811&r1=1428810&r2=1428811&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
Fri Jan 4 11:48:31 2013
@@ -42,10 +42,9 @@ import static org.apache.chemistry.openc
import static
org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createContentStream;
import static
org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createCookieValue;
import static
org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createNewProperties;
-
-import static
org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createUpdateProperties;
import static
org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createPolicies;
import static
org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createRemoveAcl;
+import static
org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createUpdateProperties;
import static
org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.getSimpleObject;
import static
org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.setCookie;
import static
org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.setStatus;
@@ -81,7 +80,6 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.data.Properties;
import org.apache.chemistry.opencmis.commons.data.PropertyData;
import org.apache.chemistry.opencmis.commons.data.RenditionData;
-import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
@@ -384,9 +382,7 @@ public final class ObjectService {
// compile properties
TypeCache typeCache = new ServerTypeCacheImpl(repositoryId, service);
- // TODO: fix this!
- TypeDefinition typeDef =
typeCache.getTypeDefinitionForObject(objectIds.get(0));
- Properties properties = createUpdateProperties(cp, typeDef.getId(),
addSecondaryTypes, objectIds, typeCache);
+ Properties properties = createUpdateProperties(cp, null,
addSecondaryTypes, objectIds, typeCache);
// execute
List<BulkUpdateObjectIdAndChangeToken> result =
service.bulkUpdateProperties(repositoryId,