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