Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Programmatically delete a package after replication.

Avatar

Level 1

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 request and 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.

1 Accepted Solution

Avatar

Correct answer by
Level 2

you can use PageMgr api : pagemanager.delete(resource,boolean)  , where resource will be your custom package.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 2

you can use PageMgr api : pagemanager.delete(resource,boolean)  , where resource will be your custom package.

Avatar

Level 1

We are creating a purge service to remove old packages using JMX service.

Adobe CQ Help | How to Monitor Workflow via JMX