我尝试使用CQ5工作流来控制我的资源(特别是页面)。 我想在不同的事件上启动不同的脚本(添加/删除/修改)。我已经在每个活动上注册了一个发射器。 当我删除页面时,删除和修改事件都会被触发,因此脚本都会运行。我无法理解如何在删除时排除修改事件。
感谢您的任何建议
答案 0 :(得分:2)
删除页面时,会在实际删除页面之前创建该页面的版本。这意味着它实际上会以ModificationType VERSION_CREATED
触发PageModification事件。
您可以使用以下只记录PageModifications的Sample EventHandler验证相同内容。
@Component
@Service
@Property(name="event.topics", value=PageEvent.EVENT_TOPIC)
public class MyPageEventHandler implements EventHandler {
private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
@Override
public void handleEvent(Event event) {
PageEvent pgEvent = PageEvent.fromEvent(event);
Iterator<PageModification> modifications = pgEvent.getModifications();
while(modifications.hasNext()) {
log.info("Page Modifications are {}", modifications.next().getType());
}
}
}