001/*
002 * (C) Copyright 2006-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.contentbrowser;
023
024import java.io.Serializable;
025
026import org.nuxeo.ecm.core.api.DocumentModel;
027import org.nuxeo.ecm.platform.types.Type;
028import org.nuxeo.ecm.platform.url.api.DocumentView;
029import org.nuxeo.ecm.webapp.action.TypesTool;
030
031/**
032 * @author <a href="mailto:rcaraghin@nuxeo.com">Razvan Caraghin</a>
033 */
034public interface DocumentActions extends Serializable {
035
036    String CHILDREN_DOCUMENT_LIST = "CHILDREN_DOCUMENT_LIST";
037
038    /**
039     * Saves changes held by the given document, and updates the current document context with the new version.
040     * <p>
041     * Makes it possible to specify whether current tabs should be restored or not after edition.
042     *
043     * @since 5.7
044     * @param restoreCurrentTabs
045     * @return the JSF outcome for navigation after document edition.
046     */
047    String updateDocument(DocumentModel document, Boolean restoreCurrentTabs);
048
049    /**
050     * Updates document considering that current document model holds edited values.
051     */
052    String updateCurrentDocument();
053
054    /**
055     * Creates a document with type given by {@link TypesTool} and stores it in the context as the current changeable
056     * document.
057     * <p>
058     * Returns the create view of given document type.
059     */
060    String createDocument();
061
062    /**
063     * Creates a document with given type and stores it in the context as the current changeable document.
064     * <p>
065     * Returns the create view of given document type.
066     */
067    String createDocument(String typeName);
068
069    /**
070     * Creates the document from the changeableDocument put in request.
071     */
072    String saveDocument();
073
074    /**
075     * Creates the given document.
076     */
077    String saveDocument(DocumentModel newDocument);
078
079    /**
080     * Downloads file as described by given document view.
081     * <p>
082     * To be used by url pattern descriptors performing a download.
083     *
084     * @param docView the document view as generated through the url service
085     */
086    void download(DocumentView docView);
087
088    /**
089     * @return ecm type for current document, <code>null</code> if current doc is null.
090     */
091    Type getCurrentType();
092
093    Type getChangeableDocumentType();
094
095    /**
096     * Checks the current document write permission.
097     *
098     * @return <code>true</code> if the user has WRITE permission on current document
099     */
100    boolean getWriteRight();
101
102    /**
103     * This method is used to test whether the logged user has enough rights for the unpublish support.
104     *
105     * @return true if the user can unpublish, false otherwise
106     */
107    boolean getCanUnpublish();
108
109    void followTransition(DocumentModel changedDocument);
110
111}