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; 013 014import org.nuxeo.ecm.automation.OperationContext; 015import org.nuxeo.ecm.automation.core.Constants; 016import org.nuxeo.ecm.automation.core.annotations.Context; 017import org.nuxeo.ecm.automation.core.annotations.Operation; 018import org.nuxeo.ecm.automation.core.annotations.OperationMethod; 019import org.nuxeo.ecm.core.api.DocumentModel; 020import org.nuxeo.ecm.core.api.DocumentModelList; 021 022/** 023 * Generic fetch document operation that can be used on any context that has a document as the input. This operation is 024 * taking the context input and it is returning it as a document If the input is not a document an exception is thrown 025 * 026 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 027 */ 028@Operation(id = FetchContextDocument.ID, category = Constants.CAT_FETCH, label = "Context Document(s)", description = "Fetch the input of the context as a document or list of documents. The document will become the input for the next operation.") 029public class FetchContextDocument { 030 031 public static final String ID = "Context.FetchDocument"; 032 033 @Context 034 protected OperationContext ctx; 035 036 @OperationMethod 037 public DocumentModel run(DocumentModel doc) { 038 return doc; 039 } 040 041 @OperationMethod 042 public DocumentModelList run(DocumentModelList docs) { 043 return docs; 044 } 045 046}