2

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:

  1. nodeService.getAspects(nodeRef) return all defined aspects for item, cm:countable presents in this list.
  2. nodeService.getProperty(nodeRef, QName.createQName("http://www.alfresco.org/model/content/1.0", "countable")) return null.
  3. nodeService.getProperties(nodeRef) returns all properties but no countable key is present.

I have search in alfresco sources and found CounterIncrementActionExecuter is extends ActionExecuterAbstractBase and defines executeImpl, but:

  1. executeImpl is not invoked at new list item creation.
  2. ActionExecuterAbstractBase#isApplicableType also not invoked.
  3. ActionExecuterAbstractBase#isApplicableType "looks" at applicableTypes variable which is not populatd explicitly in CounterIncrementActionExecuter. 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?

Cherry
  • 31,309
  • 66
  • 224
  • 364
  • See if this helps you.. http://stackoverflow.com/questions/38843229/auto-incrementing-unique-id-in-alfresco/ – Lista Dec 10 '16 at 14:14
  • Source code looks like `CounterIncrementActionExecuter`. I think it is better to use build-in functionality. – Cherry Dec 10 '16 at 16:36

1 Answers1

0

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.

mitpatoliya
  • 2,037
  • 12
  • 23