001/* 002 * (C) Copyright 2011 Nuxeo SA (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 * Thomas Roger <troger@nuxeo.com> 016 */ 017 018package org.nuxeo.ecm.activity; 019 020import java.io.Serializable; 021import java.util.Collection; 022import java.util.Map; 023 024/** 025 * Filter called by the {@code ActivityStreamService} to store and filter activities for specific use cases. 026 * 027 * @author <a href="mailto:troger@nuxeo.com">Thomas Roger</a> 028 * @since 5.5 029 */ 030public interface ActivityStreamFilter { 031 032 /** 033 * Returns the id of this {@code ActivityStreamFilter}. 034 */ 035 String getId(); 036 037 /** 038 * Returns {@code true} if this {@code ActivityStreamFilter} is interested in the given {@code activity}, 039 * {@code false} otherwise. 040 */ 041 boolean isInterestedIn(Activity activity); 042 043 /** 044 * Called by the {@code ActivityStreamService} when a new {@code Activity} is stored. 045 * <p> 046 * The given {@code activity} must not be modified. 047 */ 048 void handleNewActivity(ActivityStreamService activityStreamService, Activity activity); 049 050 /** 051 * Called by the {@code ActivityStreamService} before removing the activities referenced by the given 052 * {@code activityIds}. 053 * 054 * @deprecated since 5.6 055 */ 056 @Deprecated 057 void handleRemovedActivities(ActivityStreamService activityStreamService, Collection<Serializable> activityIds); 058 059 /** 060 * Called by the {@code ActivityStreamService} before removing the given {@code activities}. 061 * 062 * @since 5.6 063 */ 064 void handleRemovedActivities(ActivityStreamService activityStreamService, ActivitiesList activities); 065 066 /** 067 * Called by the {@code ActivityStreamService} before removing the given {@code activityReply}. 068 * 069 * @since 5.6 070 */ 071 void handleRemovedActivityReply(ActivityStreamService activityStreamService, Activity activity, 072 ActivityReply activityReply); 073 074 /** 075 * Returns the list of activities filtered by the given parameters. 076 * 077 * @param activityStreamService the main {@code ActivityStreamService} 078 * @param parameters this query parameters. 079 * @param offset the offset (starting at 0) into the list of activities. 080 * @param limit the maximum number of activities to retrieve, or 0 for all of them. 081 */ 082 ActivitiesList query(ActivityStreamService activityStreamService, Map<String, Serializable> parameters, 083 long offset, long limit); 084 085}