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