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 * @param comment 079 */ 080 void validatorPublishDocument(PublishedDocument publishedDocument, String comment); 081 082 /** 083 * A validator (the current user) rejects the publication. 084 * 085 * @param publishedDocument the currently published document that will be rejected 086 * @param comment 087 */ 088 void validatorRejectPublication(PublishedDocument publishedDocument, String comment); 089 090 /** 091 * Returns {@code true} if the current user can publish to the specified publicationNode, {@code false} otherwise. 092 * 093 * @return {@code true} if the current user can publish to the specified publicationNode, {@code false} otherwise. 094 */ 095 boolean canPublishTo(PublicationNode publicationNode); 096 097 /** 098 * Returns {@code true} if the current user can unpublish the given publishedDocument, {@code false} otherwise. 099 * 100 * @return {@code true} if the current user can unpublish the given publishedDocument, {@code false} otherwise. 101 */ 102 boolean canUnpublish(PublishedDocument publishedDocument); 103 104 boolean hasValidationTask(PublishedDocument publishedDocument); 105 106 /** 107 * Returns {@code true} if the current user can manage the publishing of the given publishedDocument, ie approve or 108 * reject the document. 109 */ 110 boolean canManagePublishing(PublishedDocument publishedDocument); 111 112 PublishedDocument wrapToPublishedDocument(DocumentModel documentModel); 113 114 /** 115 * Returns {@code true} if the given {@code documentModel} is a PublicationNode of the current tree, {@code false} 116 * otherwise. 117 */ 118 boolean isPublicationNode(DocumentModel documentModel); 119 120 /** 121 * Returns a PublicationNode for the current tree built on the given {@code documentModel}. 122 */ 123 PublicationNode wrapToPublicationNode(DocumentModel documentModel); 124 125}