STrojette
Returning Observer

Find unused content in FS

Hallo everyone,

I am having a request from one of our customers to find any "dead content" within their FirstSpirit.

They host a lot of pdf files containing product information and if that product gets removed from the store, the files aren't always deleted completely.

Is there a good/easy way to scan the whole content for files/media that aren't accessable?

0 Kudos
2 Replies
mikula
Crownpeak employee

Hey Sammy i guess you could write a script for that i guess something like this should work:

    private List<StoreElement> getChildElementsWithoutReferences(StoreElement rootElement) {

        List<StoreElement> allElements = new ArrayList<>();

        Listable<StoreElement> childElements = rootElement.getChildren();

        if (childElements.toList().size() > 0) {

            for (StoreElement element : childElements) {

                allElements.addAll(getChildElementsWithoutReferences(element));

            }

        } else {

            ReferenceEntry[] incomingReferences = rootElement.getIncomingReferences();

            if (incomingReferences.length == 0) {

                allElements.add(rootElement);

            }

        }

        return allElements;

    }

0 Kudos
pavone
I'm new here

Hello Sammy, 

do you need further help or did Martin's reply already help you? If so, it would be great if you marked his reply as "correct answer" so that other community users find the solution easily. If you have already found a solution by yourself, it would be very kind of you, if you posted it here. 

Best regards 

Tim

0 Kudos