As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
Primary Path: /{http://www.alfresco.org/model/content/1.0}categoryRoot/{http://www.alfresco.org/model/content/1.0}generalclassifiable/{http://www.alfresco.org/model/content/1.0}Old Category Name
{http://www.alfresco.org/model/content/1.0}name = Updated Category Name
HiIf you wish the PATH and the name to be in sync for catageories you need to change cm:name AND the local name on the child association to the category. The association name is used in the PATH and not cm:name. The FileFolder Service keeps these two in sync. There is no such contract for any other service (e.g. the category service) . Changing the name of a category is independant of its path. Andy
public class NameQNameSynchBehaviour implements OnUpdatePropertiesPolicy, OnMoveNodePolicy { /** a class specific logger */ private Logger logger = Logger.getLogger(NameQNameSynchBehaviour.class); PocService pocService; public void onUpdateProperties( NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after) { logger.debug("onUpdateProperties: " + nodeRef); // name changes String nameBefore = before.get(ContentModel.PROP_NAME); String nameAfter = after.get(ContentModel.PROP_NAME); boolean nameChanged = (nameBefore != null && nameBefore != nameAfter) if (nameChanged==true) { logger.debug("Poc name has changed – nameBefore: $nameBefore, nameAfter: $nameAfter"); ChildAssociationRef newChildRef = pocService.changePrimaryParent2ChildAssocQName(nodeRef, nameAfter); logger.debug("Poc qname has been synched: ${newChildRef.getQName()}"); } } /* * (non-Javadoc) * * @see * org.alfresco.repo.node.NodeServicePolicies.OnDeleteNodePolicy#onDeleteNode * (org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) */ public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) { logger.debug("onMoveNode - OLD: " + oldChildAssocRef + " - NEW: " + newChildAssocRef); // track qname changes (we can't do any more here) QName qnameBefore = oldChildAssocRef.getQName(); QName qnameAfter = newChildAssocRef.getQName(); boolean qnameChanged = (!qnameBefore.equals(qnameAfter)); if (qnameChanged==true) { logger.debug("Poc qname has changed – qnameBefore: $qnameBefore, qnameAfter: $qnameAfter"); // FIXME we can't backward-synch the cm:name, cause the qname may be a cutted version of a longer name } } } public class PocService { NodeService nodeService; public QName createNewChildAssocQName(ChildAssociationRef childAssoc, String newNameWithExt) { String localName = QName.createValidLocalName(newNameWithExt); // name will be croped to a maximum of 100 chars return QName.createQName(childAssoc.getQName().getNamespaceURI(), localName); } public ChildAssociationRef changePrimaryParent2ChildAssocQName(NodeRef node, String newNameWithExt) { return changeChildAssocQName(nodeService.getPrimaryParent(node), newNameWithExt); } public ChildAssociationRef changeChildAssocQName(ChildAssociationRef childAssoc, String newNameWithExt) { QName newAssocQName = createNewChildAssocQName(childAssoc, newNameWithExt); if (newAssocQName.equals(childAssoc.getQName())) { return childAssoc; // qname has not changed! } return nodeService.moveNode( childAssoc.getChildRef(), childAssoc.getParentRef(), childAssoc.getTypeQName(), newAssocQName); } }