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.DocumentLocation;
024import org.nuxeo.ecm.core.api.DocumentModel;
025
026/**
027 * Remote interface used by PublicationService to communicate with each others.
028 *
029 * @author tiry
030 */
031public interface RemotePublicationTreeManager {
032
033    List<PublishedDocument> getChildrenDocuments(PublicationNode node);
034
035    List<PublicationNode> getChildrenNodes(PublicationNode node);
036
037    PublicationNode getParent(PublicationNode node);
038
039    PublicationNode getNodeByPath(String sid, String path);
040
041    List<PublishedDocument> getExistingPublishedDocument(String sid, DocumentLocation docLoc);
042
043    List<PublishedDocument> getPublishedDocumentInNode(PublicationNode node);
044
045    PublishedDocument publish(DocumentModel doc, PublicationNode targetNode);
046
047    PublishedDocument publish(DocumentModel doc, PublicationNode targetNode, Map<String, String> params);
048
049    void unpublish(DocumentModel doc, PublicationNode targetNode);
050
051    void unpublish(String sid, PublishedDocument publishedDocument);
052
053    Map<String, String> initRemoteSession(String treeConfigName, Map<String, String> params);
054
055    /**
056     * Sets the current document on which the tree will be based, if needed. Can be useful for some implementations that
057     * need to know on which document the user is.
058     *
059     * @param currentDocument the current document
060     */
061    void setCurrentDocument(String sid, DocumentModel currentDocument);
062
063    void release(String sid);
064
065    /**
066     * A validator (the current user) approves the publication.
067     *
068     * @param publishedDocument the current published document that will be approved
069     * @param comment
070     */
071    void validatorPublishDocument(String sid, PublishedDocument publishedDocument, String comment);
072
073    /**
074     * A validator (the current user) rejects the publication.
075     *
076     * @param publishedDocument the currently published document that will be rejected
077     * @param comment
078     */
079    void validatorRejectPublication(String sid, PublishedDocument publishedDocument, String comment);
080
081    /**
082     * Returns {@code true} if the current user can publish to the specified publicationNode, {@code false} otherwise.
083     *
084     * @return {@code true} if the current user can publish to the specified publicationNode, {@code false} otherwise.
085     */
086    boolean canPublishTo(String sid, PublicationNode publicationNode);
087
088    /**
089     * Returns {@code true} if the current user can unpublish the given publishedDocument, {@code false} otherwise.
090     *
091     * @return {@code true} if the current user can unpublish the given publishedDocument, {@code false} otherwise.
092     */
093    boolean canUnpublish(String sid, PublishedDocument publishedDocument);
094
095    boolean hasValidationTask(String sid, PublishedDocument publishedDocument);
096
097    /**
098     * Returns {@code true} if the current user can manage the publishing of the given published document, ie. approve
099     * or reject the document.
100     */
101    boolean canManagePublishing(String sid, PublishedDocument publishedDocument);
102
103    PublishedDocument wrapToPublishedDocument(String sid, DocumentModel documentModel);
104
105    /**
106     * Returns {@code true} if the given {@code documentModel} is a PublicationNode of the current tree, {@code false}
107     * otherwise.
108     */
109    boolean isPublicationNode(String sid, DocumentModel documentModel);
110
111    /**
112     * Returns a PublicationNode for the current tree built on the given {@code documentModel}.
113     */
114    PublicationNode wrapToPublicationNode(String sid, DocumentModel documentModel);
115
116}