问题
I have added:
<mandatory-aspects>
<aspect>cm:countable</aspect>
</mandatory-aspects>
To list definition, so every item should have "increment" field. But when list items are created nothig happened. I have check the follwoing code:
nodeService.getAspects(nodeRef)
return all defined aspects for item,cm:countable
presents in this list.nodeService.getProperty(nodeRef, QName.createQName("http://www.alfresco.org/model/content/1.0", "countable"))
return null.nodeService.getProperties(nodeRef)
returns all properties but nocountable
key is present.
I have search in alfresco sources and found CounterIncrementActionExecuter
is extends ActionExecuterAbstractBase
and defines executeImpl
, but:
executeImpl
is not invoked at new list item creation.ActionExecuterAbstractBase#isApplicableType
also not invoked.ActionExecuterAbstractBase#isApplicableType
"looks" atapplicableTypes
variable which is not populatd explicitly inCounterIncrementActionExecuter
. So it is unclear how it should be populated and when.
So the question is - how does cm:countable
aspect actually works in alfresco?
UDPATE
As I see counter is incremented in java code. So is safe to use it with one database and multuple alfresco instances connected to db?
回答1:
This aspect is used generally by Alfresco administrator.It automatically increments the value of a number (integer) property when node is hit by services. This will generally only be used by Alfresco Administrators
cm:countable aspect has property called cm:counter which keeps track of current count.
So, your code for fetching property should be.
nodeService.getProperty(nodeRef, QName.createQName("http://www.alfresco.org/model/content/1.0", "counter"))
Now it works based on policy which is tied to that aspect. So, whenever node is invoked that counter is incremented.
来源:https://stackoverflow.com/questions/41076223/how-does-cmcountable-aspect-works-in-alfresco