001/*
002 * (C) Copyright 2006-2009 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 *     Nuxeo
016 */
017
018package org.nuxeo.ecm.platform.publisher.api;
019
020import java.util.List;
021import java.util.Map;
022
023import org.nuxeo.ecm.core.api.CoreSession;
024import org.nuxeo.ecm.core.api.DocumentLocation;
025import org.nuxeo.ecm.core.api.DocumentModel;
026
027/**
028 * Interface for the publication tree. A Publication Tree is a generic view on a set of PublicationNode.
029 *
030 * @author tiry
031 */
032public interface PublicationTree extends PublicationNode {
033
034    PublicationNode getNodeByPath(String path);
035
036    PublishedDocument publish(DocumentModel doc, PublicationNode targetNode);
037
038    PublishedDocument publish(DocumentModel doc, PublicationNode targetNode, Map<String, String> params);
039
040    void unpublish(DocumentModel doc, PublicationNode targetNode);
041
042    void unpublish(PublishedDocument publishedDocument);
043
044    List<PublishedDocument> getExistingPublishedDocument(DocumentLocation docLoc);
045
046    List<PublishedDocument> getPublishedDocumentInNode(PublicationNode node);
047
048    String getConfigName();
049
050    String getTreeType();
051
052    String getTreeTitle();
053
054    void initTree(String sid, CoreSession coreSession, Map<String, String> parameters,
055            PublishedDocumentFactory factory, String configName, String title);
056
057    /**
058     * Sets the current document on which the tree will be based, if needed.
059     * <p>
060     * Can be useful for some implementations that need to know on which document the user is.
061     *
062     * @param currentDocument the current document
063     */
064    void setCurrentDocument(DocumentModel currentDocument);
065
066    void release();
067
068    String getIconExpanded();
069
070    String getIconCollapsed();
071
072    /**
073     * A validator (the current user) approves the publication.
074     *
075     * @param publishedDocument the current published document that will be approved
076     * @param comment
077     */
078    void validatorPublishDocument(PublishedDocument publishedDocument, String comment);
079
080    /**
081     * A validator (the current user) rejects the publication.
082     *
083     * @param publishedDocument the currently published document that will be rejected
084     * @param comment
085     */
086    void validatorRejectPublication(PublishedDocument publishedDocument, String comment);
087
088    /**
089     * Returns {@code true} if the current user can publish to the specified publicationNode, {@code false} otherwise.
090     *
091     * @return {@code true} if the current user can publish to the specified publicationNode, {@code false} otherwise.
092     */
093    boolean canPublishTo(PublicationNode publicationNode);
094
095    /**
096     * Returns {@code true} if the current user can unpublish the given publishedDocument, {@code false} otherwise.
097     *
098     * @return {@code true} if the current user can unpublish the given publishedDocument, {@code false} otherwise.
099     */
100    boolean canUnpublish(PublishedDocument publishedDocument);
101
102    boolean hasValidationTask(PublishedDocument publishedDocument);
103
104    /**
105     * Returns {@code true} if the current user can manage the publishing of the given publishedDocument, ie approve or
106     * reject the document.
107     */
108    boolean canManagePublishing(PublishedDocument publishedDocument);
109
110    PublishedDocument wrapToPublishedDocument(DocumentModel documentModel);
111
112    /**
113     * Returns {@code true} if the given {@code documentModel} is a PublicationNode of the current tree, {@code false}
114     * otherwise.
115     */
116    boolean isPublicationNode(DocumentModel documentModel);
117
118    /**
119     * Returns a PublicationNode for the current tree built on the given {@code documentModel}.
120     */
121    PublicationNode wrapToPublicationNode(DocumentModel documentModel);
122
123}