Discussion:
[opencms-dev] abort a publish
Dudu Zoltan
2014-07-28 18:19:25 UTC
Permalink
Hi,
I have an action class that listens to
I_CmsEventListener.EVENT_BEFORE_PUBLISH_PROJECT event and perform some
actions in response

I want to abort the publish if there is an error
I looked at CmsPublishManager but how can I use it from the cmsEvent()
method?
thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20140728/c1ba06d1/attachment.html>
Sandrine Prousteau
2014-10-16 14:28:12 UTC
Permalink
I just found this :

Make a Module action class, and in initialize, do this:

PublishEventListener listener = new PublishEventListener();
OpenCms.addCmsEventListener(listener);

With your PublishEventListener implementing I_CmsEventListener, I_CmsPublishEventListener

Then in your PublishEventListener class, do this:

public void cmsEvent(CmsEvent event) {
if(event.getType()==I_CmsEventListener.EVENT_BEFORE_PUBLISH_PROJECT){
LOG.debug("Start cmsEvent EVENT_BEFORE_PUBLISH_PROJECT...");
OpenCms.getPublishManager().addPublishListener(this);
LOG.debug("End cmsEvent EVENT_BEFORE_PUBLISH_PROJECT...");
}
}

So this class is also loaded with publishManager after a publish request.

And then your can add in the same class :

public void onStart(CmsPublishJobEnqueued job) {
LOG.debug("Start onStart...");
//do wath you want with the job
LOG.debug("End onStart...");
}


De : opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] De la part de Dudu Zoltan
Envoy? : lundi 28 juillet 2014 20:19
? : The OpenCms mailing list
Objet : [opencms-dev] abort a publish

Hi,
I have an action class that listens to I_CmsEventListener.EVENT_BEFORE_PUBLISH_PROJECT event and perform some actions in response

I want to abort the publish if there is an error
I looked at CmsPublishManager but how can I use it from the cmsEvent() method?
thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20141016/ccbc478c/attachment.html>
Loading...