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.Map; 021 022import org.nuxeo.ecm.core.api.CoreSession; 023import org.nuxeo.ecm.core.api.DocumentModel; 024import org.nuxeo.ecm.platform.publisher.rules.ValidatorsRule; 025 026/** 027 * Interface of the pluggable factory used to create a PublishedDocument in a give PublicationTree. 028 * 029 * @author tiry 030 */ 031public interface PublishedDocumentFactory { 032 033 String getName(); 034 035 PublishedDocument publishDocument(DocumentModel doc, PublicationNode targetNode); 036 037 PublishedDocument publishDocument(DocumentModel doc, PublicationNode targetNode, Map<String, String> params); 038 039 void init(CoreSession coreSession, ValidatorsRule validatorsRule, Map<String, String> parameters); 040 041 void init(CoreSession coreSession, Map<String, String> parameters); 042 043 DocumentModel snapshotDocumentBeforePublish(DocumentModel doc); 044 045 PublishedDocument wrapDocumentModel(DocumentModel doc); 046 047 /** 048 * Computes the list of publishing validators given the document model of the document just published. The string 049 * can be prefixed with 'group:' or 'user:'. If there is no prefix (no : in the string) it is assumed to be a user. 050 * 051 * @param dm a Nuxeo Core document model. (the document that just has been published) 052 * @return a list of principal names. 053 */ 054 String[] getValidatorsFor(DocumentModel dm); 055 056 /** 057 * Returns the registered section validators rule. 058 * 059 * @return a validators rule 060 */ 061 ValidatorsRule getValidatorsRule(); 062 063 /** 064 * A validator (the current user) approves the publication. 065 * 066 * @param publishedDocument the current published document that will be approved 067 * @param comment 068 */ 069 void validatorPublishDocument(PublishedDocument publishedDocument, String comment); 070 071 /** 072 * A validator (the current user) rejects the publication. 073 * 074 * @param publishedDocument the currently published document that will be rejected 075 * @param comment 076 */ 077 void validatorRejectPublication(PublishedDocument publishedDocument, String comment); 078 079 boolean hasValidationTask(PublishedDocument publishedDocument); 080 081 boolean canManagePublishing(PublishedDocument publishedDocument); 082 083}