AnsweredAssumed Answered

How to correctly add an aspect to a node?

Question asked by imphilippesimo on Oct 4, 2016
Latest reply on Oct 6, 2016 by kaynezhang

Hello,

im using alfresco public java APIs to manage an alfresco repository.

Therefore, in one of my methods, i want to add a custom aspect to a node.

i tried to do as it's mentioned in the NodeRef cookbook

ie:

QName CUSTOM_ASPECT_QNAME = QName.createQName("http://www.alfresco.org/model/content/1.0", 'treated');
       QName PROP_QNAME_MY_PROPERTY = QName.createQName("http://www.alfresco.org/model/content/1.0", 'myProperty');
       Map<QName,Serializable> aspectValues = new HashMap<QName,Serializable>();
       aspectValues.put(PROP_QNAME_MY_PROPERTY, value);
       nodeService.addAspect(nodeRef, CUSTOM_ASPECT_QNAME, aspectValues);

      

Unfortunately, i got this exception:

 

org.alfresco.service.cmr.dictionary.InvalidAspectException: 09040002 The aspect is invalid: {http://www.alfresco.org/model/content/1.0}treated

    at org.alfresco.repo.node.db.DbNodeServiceImpl.addAspect_aroundBody32(DbNodeServiceImpl.java:798)

 

Can someone tell me what am i doing wrong?

thanks

Outcomes