Thursday, 27 December 2018

Alfresco error: Node has 2 primary paths

You might get the following error while exporting the ACP file from alfresco or searching a particular noderef from node browser.

java.lang.RuntimeException: Node has 2 primary paths: (4473000, workspace://SpacesStore/10b59bea-f48b-4678-9e90-ec828776cfb7)at org.alfresco.repo.domain.node.AbstractNodeDAOImpl.getPaths(AbstractNodeDAOImpl.java:3739)at org.alfresco.repo.node.db.DbNodeServiceImpl.getPaths(DbNodeServiceImpl.java:2297)at org.alfresco.repo.node.db.DbNodeServiceImpl.getPath(DbNodeServiceImpl.java:2279)

The above error tries to indicate that a particular noderef is having two primary parents. Ideally a content or document has only one primary path and can have multiple secondary paths.
But due to some invalid data/parameters passed during creation of content, this issue might have occured.

Now to get rid of this, first we need to find out where this nodref is located.
Try searching this noderef from alfresco node browser. If it gives the above error (Node has 2 primary paths) from node browser also, try running the following script from Admin Tools > Javascript console to get the details out of the noderef.

var nodeString = "workspace://SpacesStore/10b59bea-f48b-4678-9e90-ec828776cfb7";
logger.log(nodeString);
var node = search.findNode(nodeString); //this will convert to actual noderef of alfresco
logger.log(node);
var name = node.properties["name"]; // this will fetch you the name of the content/document
//var flag = node.remove();
logger.log(name);

var parent = node.parentAssocs["cm:contains"][0].name; 
//above line will give you parent noderef/name of the problematic content, that will give you an //idea where content lies. Once you get the noderef of the parent //(using node.parentAssocs["cm:contains"][0]), search this noderef from node browser. this will //give you the path where the content lies.
//If that also doesn't work, try navigating from node browser right from company home/root //folder and see if you can reach there.

logger.log(parent);
//node.remove(); //this will remove the problematic content from the alfresco repository but you need to check whether this content can be deleted or its much important.

Once you reach the problematic content, you can check if you can delete it.
You can delete it from alfresco share UI itself (if you don't get error like 'No items' with red line).
Or you can delete it with above line in javascript console (node.remove()).

If you get this error from share UI ('No items' with red line), then you need to delete the parent folder of it after verifying the contents inside.

1 comment: