How to clean up inactive softlinks from database?

Vote:
 

We have noticed that we have a lot of softlinks that is not active anymore in one of our solutions. If we look at a document it says that it is linked to eight contents but seven of these does not have a link to that document anymore.

We think it is from a migration earlier so we have had the error for some time now and need help on what is the best way to solve it.

What we want to do is to have a solution that goes through all registred softlinks in the database and for each link verify that it still exists.

Are there any built in functions for this?

#113551
Nov 24, 2014 15:36
Vote:
 

Not that I am aware of, the code for a single content would be:

var contentSoftLinkIndexer = ServiceLocator.Current.GetInstance<ContentSoftLinkIndexer>();
var contentSoftLinkRepo = ServiceLocator.Current.GetInstance<ContentSoftLinkRepository>();

var links = contentSoftLinkIndexer.GetLinks(content);
contentSoftLinkRepo.Save(content.ContentLink.ToReferenceWithoutVersion(), content is ILocalizable ? ((ILocalizable)content).Language : null, links);}
#113556
Edited, Nov 24, 2014 16:31
Vote:
 

Thanks Per!

#113558
Nov 24, 2014 16:51
Vote:
 

Just a little info, the problem was that we had a lot of content/files that was imported from another system that had not gotten the proper language in it so they did not show in any list and was not removed when updating the pages.

We solved it by updating those rows in the contentsoftlink table with the proper language and then run a update on all the pages.

#113963
Dec 02, 2014 13:35
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.