Reputation: 1298
We have this problem:
yesterday we had custom xmlModel in Alfresco that had a custom type, extension of content with a property and some mandatory aspects.
<type name="custom:myType">
<title>Object</title>
<parent>cm:content</parent>
<properties>
<property name="custom:myProperty">
<type>d:text</type>
</property>
</properties>
<mandatory-aspects>
<aspect>custom:myAspect1</aspect>
</mandatory-aspects>
</type>
now we have the urgent need to move the custom my Property to a new aspect like this:
<aspect name="custom:myAspect2">
<title>new aspect</title>
<properties>
<property name="custom:myProperty">
<type>d:text</type>
<mandatory enforced='true'>true</mandatory>
</property>
</properties>
</aspect>
and the type is now:
<type name="custom:myType">
<title>Object</title>
<parent>cm:content</parent>
<mandatory-aspects>
<aspect>custom:myAspect1</aspect>
<aspect>custom:myAspect2</aspect>
</mandatory-aspects>
After a full rebuild index, Lucene seems not to be considering these changes. So in Alfresco on new documents everythings fine, on the old ones, uplodaded with the old model and now reindexed, we have still the property, but missing the aspect. Is that normal behaviour? or some issue/bug. All of this is caused by our need to make CMIS queries on aspects, but we have some problems making queries on a native property of a type that is not part of an aspect in Alfresco. It seems only being possible to extract properties of an aspect and not of a content type. Is that true? thanks
Thanks.
Upvotes: 0
Views: 1083
Reputation: 10538
Regarding the first part of your problem, you may need to run a script to add the aspect to the old objects. I'm actually surprised the repo was able to start because those old objects should be complaining that their type requires a mandatory aspect that hasn't been added to the object.
If I were making the change you made, I would have declared the aspect first as an empty aspect, then run a script to add the aspect to all of the nodes where it makes sense, then update the model to move the property from the type to the aspect and restart.
Regarding your second question about CMIS and queries, you should be able to query properties defined as part of a type through CMIS with no problem whatsoever. The problem is when your properties move to aspects. Then your queries have to do a join like this:
queryString = "select d.*, w.* from cmis:document as d join sc:webable as w on d.cmis:objectId = w.cmis:objectId where w.sc:isActive = True";
In this example, sc:webable is an aspect and the sc:isActive property is defined on that aspect.
So if you said you were having trouble querying properties defined on aspects, that would make more sense (because of the join requirement) than having trouble querying properties defined on types.
Also, note that adding and removing aspects to/from objects, asking an object if it has an aspect, and setting or updating properties defined on an aspect all require you to use an extension because aspects are not supported by CMIS 1.0 out-of-the-box. There is an extension for OpenCMIS and another extension for cmislib.
Upvotes: 2