001/*
002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Antoine Taillefer <ataillefer@nuxeo.com>
018 */
019package org.nuxeo.drive.service;
020
021import java.util.List;
022import java.util.Map;
023import java.util.Set;
024
025import org.nuxeo.ecm.core.api.CoreSession;
026import org.nuxeo.ecm.core.api.IdRef;
027
028/**
029 * Allows to find document changes.
030 *
031 * @author Antoine Taillefer
032 */
033public interface FileSystemChangeFinder {
034
035    /**
036     * Handles the parameters contributed through the {@code changeFinder} contribution.
037     */
038    void handleParameters(Map<String, String> parameters);
039
040    /**
041     * Gets the changes in the repository against which the given session is bound for the given synchronization root
042     * paths, between the given lower and upper integer bounds and without exceeding the given limit. The change
043     * summaries are mapped back to the file system view: the file system items might not always have the same tree
044     * layout as the backing documents in the repositories but this is a back-end detail that the client does not have
045     * to deal with.
046     *
047     * @param session the session bound to a specific repository
048     * @param lastActiveRootRefs docrefs of the roots as reported by the last successful synchronization (can be empty
049     *            or null)
050     * @param activeRoots the currently active synchronization roots
051     * @param collectionSyncRootMemberIds the collection sync root member ids
052     * @param lowerBound the lower integer bound of the range clause in the change query
053     * @param upperBound the upper integer bound of the range clause in the change query. This id is typically obtained
054     *            by calling {@link #getUpperBound())}
055     * @param limit the maximum number of changes to fetch
056     * @return the list of document changes
057     * @throws TooManyChangesException if the number of changes found has exceeded the limit
058     */
059    List<FileSystemItemChange> getFileSystemChanges(CoreSession session, Set<IdRef> lastActiveRootRefs,
060            SynchronizationRoots activeRoots, Set<String> collectionSyncRootMemberIds, long lowerBound, long upperBound,
061            int limit);
062
063    /**
064     * Return the upper bound of the range clause in the change query.
065     */
066    long getUpperBound();
067
068    /**
069     * Returns the upper bound of the range clause in the change query taking into account the clustering delay if
070     * clustering is enabled for at least one of the given repositories.
071     *
072     * @since 8.2
073     */
074    long getUpperBound(Set<String> repositoryNames);
075
076}