AnsweredAssumed Answered

P:cm:titled aspect doesn't seem to work

Question asked by mcaserta on Mar 30, 2011
Latest reply on Mar 31, 2011 by mcaserta
Hello there,
I'm trying to update the description (cm:description property) of a folder using the Alfresco OpenCIMS Extension and I think I'm missing something obvious because when I GET the application/atom+xml representation of my folder I can see it has the right aspect:

…snip…
<alf:aspects>
<alf:appliedAspects>P:app:uifacets</alf:appliedAspects>
<alf:appliedAspects>P:cm:titled</alf:appliedAspects>
<alf:properties>
<cmis:propertyString propertyDefinitionId="app:icon" displayName="Icon" queryName="app:icon"><cmis:value>space-icon-default</cmis:value></cmis:propertyString>
<cmis:propertyString propertyDefinitionId="cm:description" displayName="Description" queryName="cm:description"><cmis:value>Contact: Pippo Baudo (pippo.baudo@rai.it)</cmis:value></cmis:propertyString>
<cmis:propertyString propertyDefinitionId="cm:title" displayName="Title" queryName="cm:title"><cmis:value>Virtual District Home</cmis:value></cmis:propertyString>
</alf:properties>
</alf:aspects>
…snip…

But, if I try to access the aspects via the api, I don't see the relevant aspect. Here's the code:

        AlfrescoFolder alfrescoFolder = (AlfrescoFolder) session.getObjectByPath(alfrescoFolderPath);
        log.debug("createUserHomeFolder(): alfrescoFolder.aspects={}", alfrescoFolder.getAspects());

and here's the output:

createUserHomeFolder(): alfrescoFolder.aspects=[Type Definition [base id=CMIS_POLICY, id=P:cm:ownable, display Name=Ownable, description=Ownable, local name=ownable, local namespace=http://www.alfresco.org/model/content/1.0, query name=cm:ownable, parent id=cmis:policy, is controllable ACL=false, is controllable policy=false, is creatable=false, is fileable=false, is fulltext indexed=true, is included in supertype query=true, is queryable=true, property definitions={cm:owner=Property Definition [id=cm:owner, display name=Owner, description=Owner, local name=owner, local namespace=http://www.alfresco.org/model/content/1.0, query name=cm:owner, property type=STRING, cardinality=SINGLE, choice list=[], default value=null, is inherited=false, is open choice=false, is queryable=true, is required=false, updatability=READWRITE][extensions=null]}][extensions=null]]

Therefore, if I try to do a:

        if (alfrescoFolder.hasAspect("P:cm:titled")) {
            log.debug("createUserHomeFolder(): alfrescoFolder.hasAspect(\"P:cm:titled\")=true");
            Map<String, Object> properties = new HashMap<String, Object>();
            properties.put("cm:description", "Contact: ".concat(alfrescoUser.getFirstName()).concat(" ").concat(alfrescoUser.getLastName()).concat(" (").concat(alfrescoUser.getEmail().concat(")")));
            alfrescoFolder.updateProperties(properties);
        }

I don't see the "alfrescoFolder.hasAspect" debug statement in my logs, i.e. the condition in the if statement evaluates to false.

I have verified the objectId of the folder I'm getting via the http GET is the same as the objectId of the "alfrescoFolder" instance variable you see in my code.

Any help would be very much appreciated. Thank you.

Mirko

Outcomes