02-23-2009 12:08 AM
Primary Path:   /{http://www.alfresco.org/model/content/1.0}categoryRoot/{http://www.alfresco.org/model/content/1.0}ge... Category NameBut under the properties table a few lines down the screen:{http://www.alfresco.org/model/content/1.0}name = Updated Category NameThe first thing I did was a FULL reindexing on the server, and it did not update the paths to the new name as I had hoped it would.  One other tidbit, these categories have the "Incomplete" aspect on so there must be a mandatory property missing- perhaps this prevents it from being reindexed properly?  02-26-2009 12:30 PM
03-17-2009 05:31 PM
03-19-2009 06:10 AM
05-22-2009 07:03 PM
09-02-2009 05:41 AM
09-24-2009 08:25 AM
Hi
If 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
10-13-2009 09:34 AM
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); 
  }
  
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.