001/*
002 * (C) Copyright 2006-20012 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 *     Razvan Caraghin
016 *     Florent Guillaume
017 *     Antoine Taillefer
018 */
019
020package org.nuxeo.ecm.webapp.versioning;
021
022import org.jboss.seam.annotations.Create;
023import org.nuxeo.ecm.core.api.DocumentModel;
024import org.nuxeo.ecm.core.api.VersionModel;
025import org.nuxeo.ecm.platform.query.api.PageSelections;
026
027/**
028 * Exposes the actions that can be taken related to versioning and documents.
029 *
030 * @author Razvan Caraghin
031 * @author Florent Guillaume
032 */
033public interface VersionedActions {
034
035    /**
036     * Factory accessor for currentDocument versionList.
037     *
038     * @return the selected version list as a {@link PageSelections<VersionModel>}
039     */
040    PageSelections<VersionModel> getVersionList();
041
042    /**
043     * Retrieves the versions for the current document.
044     */
045    void retrieveVersions();
046
047    /**
048     * Restored the document to the selected version. If there is no selected version it does nothing.
049     *
050     * @return the page that needs to be displayed next
051     */
052    String restoreToVersion(VersionModel selectedVersion);
053
054    /**
055     * Restores the version which id is returned by {@link #getSelectedVersionId()}.
056     *
057     * @return the view id
058     * @since 5.6
059     */
060    String restoreToVersion();
061
062    /**
063     * Security check to enable or disable the restore button.
064     *
065     * @return permission check result
066     */
067    boolean getCanRestore();
068
069    /**
070     * Tells if the current selected document is checked out or not.
071     */
072    String getCheckedOut();
073
074    /**
075     * Changes the checked-out string.
076     *
077     * @param checkedOut
078     */
079    void setCheckedOut(String checkedOut);
080
081    /**
082     * Checks the document out.
083     *
084     * @return the next page
085     */
086    @SuppressWarnings({ "NonBooleanMethodNameMayNotStartWithQuestion" })
087    String checkOut();
088
089    /**
090     * Checks the selected document in, with the selected version.
091     */
092    String checkIn();
093
094    @Create
095    void initialize();
096
097    /**
098     * When the user selects/changes other documents then we nullify the list of versions associated with the document
099     * so that the factory method gets called when the list is used.
100     * <p>
101     * This way we achieve lazy loading of data from backend - only when its needed and not loading it when the event is
102     * fired.
103     */
104    void resetVersions();
105
106    /**
107     * View an older version of the document.
108     */
109    String viewArchivedVersion(VersionModel selectedVersion);
110
111    /**
112     * Navigates to the version which id is returned by {@link #getSelectedVersionId()}.
113     *
114     * @return the view id
115     * @since 5.6
116     */
117    String viewArchivedVersion();
118
119    DocumentModel getSourceDocument();
120
121    DocumentModel getSourceDocument(DocumentModel document);
122
123    /**
124     * Check if a version can be removed. It won't be possible if a proxy is pointing to it.
125     */
126    boolean canRemoveArchivedVersion(VersionModel selectedVersion);
127
128    /**
129     * Check if the currently selected versions can be removed. It won't be possible if a proxy is pointing to one of
130     * them.
131     *
132     * @return true if can remove selected archived versions
133     * @since 5.6
134     */
135    boolean getCanRemoveSelectedArchivedVersions();
136
137    /**
138     * Remove an archived version.
139     *
140     * @param selectedVersion the version model to remove
141     */
142    String removeArchivedVersion(VersionModel selectedVersion);
143
144    /**
145     * Remove currently selected archived versions.
146     *
147     * @since 5.6
148     */
149    String removeSelectedArchivedVersions();
150
151    /**
152     * Gets currently selected version id.
153     *
154     * @since 5.6
155     */
156    String getSelectedVersionId();
157
158    /**
159     * Sets currently selected version id.
160     *
161     * @since 5.6
162     */
163    void setSelectedVersionId(String selectedVersionId);
164}