yesterday - last edited yesterday
We have Alfresco community edition 5.2.0. I do not think this version supports Rest API endpoints.
My objective is to purge documents by a specific metadata property. I am trying to accomplish this using CMIS. This objectIdString is the UUID of the active store object.
CmisObject cmisObject = cmisSession.getObject(objectIdString);
//With this I tried:
Document document = (Document) cmisObject;
document.deleteAllVersions();
//Also tried
cmisObject.delete(true);
With either of these, only the active store object is deleted. Version and archive stores have the objects.
This is before deletion:
id | version | store_id | type_qname_id | mlo_cat | mlo_link | name6 | version | versiondesc | versionlabel | versionhistory | archivedby | archiveddate | rootversion | desc27
-----+---------+----------+---------------+---------+----------+------------+---------+-----------------+--------------+----------------+------------+--------------+-------------+--------
901 | 1 | 4 | 233 | License | 1695 | nature.jpg | | Initial Version | 1.0 | | | | |
899 | 5 | 6 | 233 | License | 1695 | nature.jpg | | | | | | | |
After deletion:
id | version | store_id | type_qname_id | mlo_cat | mlo_link | name6 | version | versiondesc | versionlabel | versionhistory | archivedby | archiveddate | rootversion | desc27
------+---------+----------+---------------+---------+----------+------------+---------+-----------------+--------------+----------------+------------+--------------------------+-------------+--------
901 | 1 | 4 | 233 | License | 1695 | nature.jpg | | Initial Version | 1.0 | | | | |
1299 | 5 | 5 | 233 | License | 1695 | nature.jpg | | | | | admin | 2025-01-23T02:44:48.363Z | |
I tried setting this in alfresco.global.properties and restarted
system.content.eagerOrphanCleanup=true
Still does not help.
Customer would like purge these documents. Even though they cannot access the deleted document, through another application, since they do not find the storage still staying the same size, they are skeptical about the deletion process.
Any recommendation is appreciated.
2 hours ago
If I add the aspect 'P:sys:temporary' and update its properties, before deleting the document, then once deleted, the document (node) is gone from the active and version2 stores, and also it does not get put into the archive store. Glad the alfresco repository that I am working with supports this aspect. Saved lots of time. Code snippet is like shown below.
public void makeTheDocumentTemporary(CmisObject docObject) {
Property<Object> secondaryTypes = docObject.getProperty("cmis:secondaryObjectTypeIds");
List<Object> aspects = (secondaryTypes != null) ? secondaryTypes.getValues() : null;
if (aspects == null) {
aspects = new ArrayList<Object>();
} else {
aspects = new ArrayList<Object>(aspects); // Defensive copy
}
if (!aspects.contains("P:sys:temporary")) {
aspects.add("P:sys:temporary");
}
HashMap<String, Object> props = new HashMap<String, Object>();
props.put("cmis:secondaryObjectTypeIds", aspects);
try {
docObject.updateProperties(props);
} catch (Exception e) {
System.err.println("Error updating aspect properties: " + e.getMessage());
}
}
Explore our Alfresco products with the links below. Use labels to filter content by product module.