001/* 002 * (C) Copyright 2006-2012 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * tmartins 016 */ 017package org.nuxeo.ecm.platform.ec.notification; 018 019import org.nuxeo.ecm.core.event.Event; 020import org.nuxeo.ecm.core.event.impl.DocumentEventContext; 021 022/** 023 * Veto not to send notification when a version is the source document of the event. Notifications on versions are not 024 * really relevant, there should be another event on the live document that provides a more specific notification For 025 * instance, use documentCheckedIn on the live document, instead of documentCreated on the version 026 * 027 * @since 5.7 028 * @author Thierry Martins <tm@nuxeo.com> 029 */ 030public class VersionVeto implements NotificationListenerVeto { 031 032 @Override 033 public boolean accept(Event event) { 034 // this cast is safe because the type checking was done in 035 // NotificationEventListener 036 DocumentEventContext docCtx = (DocumentEventContext) event.getContext(); 037 if (docCtx.getSourceDocument().isVersion()) { 038 return false; 039 } 040 return true; 041 } 042 043}