cancel
Showing results for 
Search instead for 
Did you mean: 

NodeRef change while publishing

aussen2
Champ in-the-making
Champ in-the-making
Could you please explain how you handle the nodeRef mapping when publishing assets in WQS? My understanding is that normally the Transfer Service will make sure that a transferred node gets the same nodeRef in the target repository that is has in the source repository. Obviously that cannot be the case for the "adjusted" Transfer Service that WQS publishing is using (because source and target is the same repository). I found that the nodeRefs for published nodes in WQS only slightly differ from their source nodes' nodeRefs. So I assume that these nodeRefs are somehow created programmatically. Can you explain how exactly this is working?

The reason I am asking is this use case: As Alfresco doesn't support complex data types we are "augmenting" associations between nodes with additional data stored in serialized form in a text field (d:text). We use custom form components to display and update this additional data alongside the associations. They also map the additional data to its corresponding associated node. So if we for example have an article node that has two image nodes (workspace://SpacesStore/d6e441a7-a4e1-4c21-96bf-20583aa9e5d1 and workspace://SpacesStore/e9f552b8-b5f2-5d32-07cg-31694bb0f6e2) associated, the content of the text field with the additional data might look something like this:

nodeRef=workspace://SpacesStore/d6e441a7-a4e1-4c21-96bf-20583aa9e5d1|oderIndex=1|isGallery=true|hasAnotherProperty=false,
nodeRef=workspace://SpacesStore/e9f552b8-b5f2-5d32-07cg-31694bb0f6e2|oderIndex=2|isGallery=false|hasAnotherProperty=false

Now this mapping breaks when the nodeRef changes while publishing. Thus, I was wondering if there is at least some part of the nodeRef that is persistent. That seems to be the case for the published nodes that we observed. But in order to count on this we would need to understand the mechanism behind the nodeRef creation process in this special case.
1 REPLY 1

aussen2
Champ in-the-making
Champ in-the-making
Okay, I found the logic that I was looking for in org.alfresco.module.org_alfresco_module_wcmquickstart.publish.NodeRefMapper:


public NodeRef mapSourceNodeRef(NodeRef node)
    {
        StringBuilder nodeId = new StringBuilder(node.getId());
        if (nodeId.length() == 36)
        {
            for (int index = 35; index >= 0; –index)
            {
                int srcChar = nodeId.charAt(index);
                if (srcChar == '-')
                {
                    continue;
                }
                int destChar = srcCharToDestChar(srcChar);
                if (destChar != srcChar)
                {
                    nodeId.setCharAt(index, (char)destChar);
                    break;
                }
            }
        }
        else
        {
            nodeId.append('f');
        }
        return new NodeRef(node.getStoreRef(), nodeId.toString());
    }

As the change logic for the nodeRef string starts at the last character and stops once a character was successfully substituted I assume it is save to use the first 20 characters of the nodeRef for our use case. These should go unchanged when publishing nodes in WQS as well as between two repositories in more than 99% of all cases.