001/*
002 * (C) Copyright 2012 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 *     Antoine Taillefer <ataillefer@nuxeo.com>
016 */
017package org.nuxeo.drive.service;
018
019import org.nuxeo.drive.adapter.impl.DocumentBackedFileItem;
020import org.nuxeo.drive.service.impl.DefaultFileSystemItemFactory;
021import org.nuxeo.ecm.core.api.CoreSession;
022import org.nuxeo.ecm.core.api.DocumentModel;
023import org.nuxeo.ecm.core.api.VersioningOption;
024
025/**
026 * A {@link FileSystemItemFactory} able to handle versioning.
027 *
028 * @author Antoine Taillefer
029 * @see DefaultFileSystemItemFactory
030 */
031public interface VersioningFileSystemItemFactory extends FileSystemItemFactory {
032
033    /**
034     * Returns true if the given {@link DocumentModel} needs to be versioned. An example of policy could be to version
035     * the document if the last modification was done more than {@link #getVersioningDelay()} seconds ago.
036     *
037     * @see DocumentBackedFileItem#versionIfNeeded(DocumentModel doc, CoreSession session)
038     */
039    boolean needsVersioning(DocumentModel doc);
040
041    /**
042     * Gets the delay passed which a document needs to be versioned since its last modification.
043     *
044     * @see DefaultFileSystemItemFactory#needsVersioning(DocumentModel)
045     */
046    double getVersioningDelay();
047
048    /**
049     * Sets the delay passed which a document needs to be versioned since its last modification.
050     */
051    void setVersioningDelay(double versioningDelay);
052
053    /**
054     * Gets the increment option used when versioning a document.
055     *
056     * @see DocumentBackedFileItem#versionIfNeeded(DocumentModel doc, CoreSession session)
057     */
058    VersioningOption getVersioningOption();
059
060    /**
061     * Sets the increment option used when versioning a document.
062     */
063    void setVersioningOption(VersioningOption versioningOption);
064
065}