cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove aspect for all documents in Alfresco at once?

miroslav
Star Contributor
Star Contributor

Hello,

when alfresco was migrated to a newer version (5.2->7.x), incompatible extensions were removed (not installed), and also their custom model is missing (aspects and its properties). Files and folders In Alfresco have this metadata marked with a special flag and the document cannot be edited in Share (Edit Properties). I created missing custom model again by model modeler and it seems it worked well.

In this moment, I would like to remove old unnecessary aspect from all documents in the system, how to do that?

Thank you!


1 REPLY 1

abhinavmishra14
World-Class Innovator
World-Class Innovator

You can create a javabacked or javascript webscript to cleanup your content in bulk based on given parameters.

Here is an example of applying aspect in bulk, in same way you can remove aspects via the script:

https://hub.alfresco.com/t5/alfresco-content-services-forum/is-there-any-endpoint-in-alfresco-that-a...

Since content model is no longer available and your content may have aspects and properties, the script will throw integrity violation error, you will have to disable the behaviors that run the validation in the backgroud. 

example;

 var webContext = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
 var behaviourFilter = webContext.getBean("policyBehaviourFilter", org.alfresco.repo.policy.BehaviourFilter);
 // Disable all behaviors, so we can remove the aspect without any validations
 behaviourFilter.disableAllBehaviours();

 if(node.hasAspect(aspectName)){
     // Remove aspect
    node.removeAspect(aspectName);
 }
 
 // Enable all the behaviors
 behaviourFilter.enableAllBehaviours(); 
~Abhinav
(ACSCE, AWS SAA, Azure Admin)