001/*
002 * (C) Copyright 2007 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 *     Nuxeo - initial API and implementation
016 *
017 * $Id$
018 */
019
020package org.nuxeo.ecm.webapp.edit.lock;
021
022import java.io.Serializable;
023import java.util.Map;
024
025import org.nuxeo.ecm.core.api.DocumentModel;
026import org.nuxeo.ecm.platform.actions.Action;
027
028/**
029 * Interface for an action listener that will provide methods to lock/unlock a document, to lock/unlock the current
030 * document and to lock/unlock a list of documents (based on DocumentsListManager).
031 *
032 * @author <a href="mailto:bt@nuxeo.com">Bogdan Tatar</a>
033 */
034public interface LockActions extends Serializable {
035
036    String LOCKER = "document.locker";
037
038    /** @deprecated since 5.4.2, use {@link #LOCK_CREATED} instead */
039    @Deprecated
040    String LOCK_TIME = "document.lock.time";
041
042    /** @since 5.4.2 */
043    String LOCK_CREATED = "document.lock.created";
044
045    /**
046     * Gets the lock of the current document.
047     *
048     */
049    String lockCurrentDocument();
050
051    /**
052     * Releases the lock of the current document.
053     *
054     */
055    String unlockCurrentDocument();
056
057    /**
058     * Gets the lock of the document.
059     *
060     * @param document the document of which lock is to be taken
061     */
062    String lockDocument(DocumentModel document);
063
064    /**
065     * Releases the lock of the document.
066     *
067     * @param document the document of which lock is to be released
068     */
069    String unlockDocument(DocumentModel document);
070
071    /**
072     * Tests if the user can get the lock of a document.
073     *
074     * @return true if the user has this right, false otherwise
075     */
076    Boolean getCanLockDoc(DocumentModel document);
077
078    /**
079     * Tests if the user can get the lock of the current document.
080     *
081     * @return true if the user has this right, false otherwise
082     */
083    Boolean getCanLockCurrentDoc();
084
085    /**
086     * Tests if the user can unlock a document.
087     *
088     * @return true if the user has this right, false otherwise
089     */
090    Boolean getCanUnlockDoc(DocumentModel document);
091
092    /**
093     * Tests if the user can unlock the current document.
094     *
095     * @return true if the user has this right, false otherwise
096     */
097    Boolean getCanUnlockCurrentDoc();
098
099    /**
100     * Returns the action of lock or unlock for a document.
101     *
102     * @return the action of lock or unlock for a document
103     */
104    Action getLockOrUnlockAction();
105
106    /**
107     * Gets the details about the lock of a document,who did the lock and when the lock took place.
108     *
109     * @param document the document for which this information is needed
110     * @return the user who took the look and the time when he/she did this in a map
111     */
112    Map<String, Serializable> getLockDetails(DocumentModel document);
113
114    /**
115     * Gets the details about the lock of the current document, who did the lock and when the lock took place.
116     *
117     * @return the user who took the look and the time when he/she did this in a map
118     */
119    Map<String, Serializable> getCurrentDocLockDetails();
120
121    void resetLockState();
122
123}