How to remove aspect for all documents in Alfresco at once?
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?
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.
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
// Remove aspect
// Enable all the behaviors