cancel
Showing results for 
Search instead for 
Did you mean: 

ClassCastExpception in extended content model

gressho
Champ in-the-making
Champ in-the-making
Hello,

I' using the CMIS implementation of Alfresco 3.2 and have defined my own content model extension with some properties which should
occur multiple times:


        <type name="ma:document">
            <title>Dokument</title>
            <parent>cm:folder</parent>
            <properties>
                <property name="ma:docPersonId">
                    <title>Personen-IDs</title>
                    <type>d:text</type>
                    <multiple>true</multiple>
                </property>
                <property name="ma:docOrganisationId">
                    <title>Einrichtungs-IDs</title>
                    <type>d:text</type>
                    <multiple>true</multiple>
                </property>
                <property name="ma:docClassificationId">
                    <title>Klassifikations-IDs</title>
                    <type>d:text</type>
                    <multiple>true</multiple>
                </property>
            </properties>
        </type>

When I want to add multiple elements to these extensions with the following code


        CmisPropertyString classificationProperty = new CmisPropertyString();
        classificationProperty.setName(DOCUMENT_CLASSIFICATION_ID);
        for (Classification classification : document.getClassifications()) {
            classificationProperty.getValue().add(classification.getUuid());
        }

I'm ending up in a ClassCastException:
javax.xml.ws.soap.SOAPFaultException: Runtime error. Message: java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.String

I couldn't find a Jira task for this and I don't know if my code or assumptions are correct (according to the spec this should be working).

Best wishes

Werner Greßhoff
2 REPLIES 2

mariusz_pala
Champ in-the-making
Champ in-the-making
Hi,

I'm using version 3.2r2 and I have the same issue. According to the code CMIS implementation doesn't support multiple properties…
Can you tell us when is going to support it? This is really critical issue.

java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.String
        at org.alfresco.repo.cmis.ws.utils.PropertyUtil.checkProperty(PropertyUtil.java:488)
        at org.alfresco.repo.cmis.ws.utils.PropertyUtil.setProperties(PropertyUtil.java:395)
        at org.alfresco.repo.cmis.ws.DMObjectServicePort.updateProperties(DMObjectServicePort.java:658)

Thanks.
Mariusz

kbryd
Champ in-the-making
Champ in-the-making
Here is a simple patch I have knocked together:

— PropertyUtil.java   2009-10-31 06:47:36.000000000 +0100
+++ /home/kbryd/work/alfresco/remote-api-3.2r2/java/org/alfresco/repo/cmis/ws/utils/PropertyUtil.java   2010-01-17 21:29:28.872800626 +0100
@@ -485,13 +485,23 @@
         {
         case STRING:
         {
-            checkStringProperty(propertyDefinition, propertyName, (String) value);
+            if(value instanceof Collection) {
+                Collection<String> c = (Collection)value;
+                for(String s : c)
+                    checkStringProperty(propertyDefinition, propertyName, s);
+            } else
+                checkStringProperty(propertyDefinition, propertyName, (String) value);
             break;
         }
         case INTEGER:
         case DECIMAL:
         {
-            checkNumberProperty(propertyDefinition, propertyName, (Number) value);
+            if(value instanceof Collection) {
+                Collection<Number> c = (Collection)value;
+                for(Number s : c)
+                    checkNumberProperty(propertyDefinition, propertyName, s);
+            } else
+                checkNumberProperty(propertyDefinition, propertyName, (Number) value);
             break;
         }
         }
@@ -558,7 +568,6 @@
     {
         String typeId = properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID) != null ? properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID).toString() : null;
         CMISTypeDefinition type = cmisDictionaryService.findType(typeId);
-
         if (null == type)
         {
             throw cmisObjectsUtils.createCmisException(("Type with " + typeId + " typeId was not found"), EnumServiceException.RUNTIME);