In our current implementation of programatic package creation and replication to boost performance we have two flows:
1. Programmatically create a package of name admin_package.zip which uses com.day.cq.wcm.api.PageManager.create(path, packagename) when ever activation of home page is detected.
2. Replicate package created in step1 using com.day.cq.replication.Replicator.replicate(session, ReplicationActionType.ACTIVATE, package.getNode().getPath());
The issue with this implementation is that whenever more than one author is activating the content (concurrent activation issue even though different pages) code is creating package of same name which is "admin_package.zip" for both the authors as both of them issued activation requests at the same time. This is throwing javax.jcr.ItemExistsException for second concurrent requestand replication fails for that request.
So what we are assuming that we will add time stamp to the package name and then delete programatically the package after replication.
I am not getting the code how to do efficient deletion of package after replication in code. Has anyone done this type of implementation.
Or anyone has similar problem but followed a different approach.
Please let me know ideas and implementation details.