001/* 002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * bstefanescu 011 */ 012package org.nuxeo.ecm.automation.core.operations.document; 013 014import org.nuxeo.ecm.automation.core.Constants; 015import org.nuxeo.ecm.automation.core.annotations.Context; 016import org.nuxeo.ecm.automation.core.annotations.Operation; 017import org.nuxeo.ecm.automation.core.annotations.OperationMethod; 018import org.nuxeo.ecm.automation.core.annotations.Param; 019import org.nuxeo.ecm.automation.core.collectors.DocumentModelCollector; 020import org.nuxeo.ecm.core.api.CoreSession; 021import org.nuxeo.ecm.core.api.DocumentModel; 022 023/** 024 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 025 */ 026@Operation(id = PublishDocument.ID, category = Constants.CAT_DOCUMENT, label = "Publish Document", description = "Publish the input document into the target section. Existing proxy is overrided if the override attribute is set. Return the created proxy.", aliases = { "Document.Publish" }) 027public class PublishDocument { 028 029 public static final String ID = "Document.PublishToSection"; 030 031 @Context 032 protected CoreSession session; 033 034 @Param(name = "target") 035 protected DocumentModel target; 036 037 @Param(name = "override", required = false, values = "true") 038 protected boolean override = true; 039 040 @OperationMethod(collector = DocumentModelCollector.class) 041 public DocumentModel run(DocumentModel doc) { 042 return session.publishDocument(doc, target, override); 043 } 044 045}