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