001/*
002 * (C) Copyright 2006-2009 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
018 */
019
020package org.nuxeo.ecm.platform.publisher.api;
021
022import java.util.List;
023import java.util.Map;
024
025import org.nuxeo.ecm.core.api.CoreSession;
026import org.nuxeo.ecm.core.api.DocumentLocation;
027import org.nuxeo.ecm.core.api.DocumentModel;
028
029/**
030 * Interface for the publication tree. A Publication Tree is a generic view on a set of PublicationNode.
031 *
032 * @author tiry
033 */
034public interface PublicationTree extends PublicationNode {
035
036    PublicationNode getNodeByPath(String path);
037
038    PublishedDocument publish(DocumentModel doc, PublicationNode targetNode);
039
040    PublishedDocument publish(DocumentModel doc, PublicationNode targetNode, Map<String, String> params);
041
042    void unpublish(DocumentModel doc, PublicationNode targetNode);
043
044    void unpublish(PublishedDocument publishedDocument);
045
046    List<PublishedDocument> getExistingPublishedDocument(DocumentLocation docLoc);
047
048    List<PublishedDocument> getPublishedDocumentInNode(PublicationNode node);
049
050    String getConfigName();
051
052    String getTreeType();
053
054    String getTreeTitle();
055
056    void initTree(CoreSession coreSession, Map<String, String> parameters, PublishedDocumentFactory factory,
057            String configName, String title);
058
059    /**
060     * Sets the current document on which the tree will be based, if needed.
061     * <p>
062     * Can be useful for some implementations that need to know on which document the user is.
063     *
064     * @param currentDocument the current document
065     */
066    void setCurrentDocument(DocumentModel currentDocument);
067
068    void release();
069
070    String getIconExpanded();
071
072    String getIconCollapsed();
073
074    /**
075     * A validator (the current user) approves the publication.
076     *
077     * @param publishedDocument the current published document that will be approved
078     */
079    void validatorPublishDocument(PublishedDocument publishedDocument, String comment);
080
081    /**
082     * A validator (the current user) rejects the publication.
083     *
084     * @param publishedDocument the currently published document that will be rejected
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}