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; 022import org.nuxeo.ecm.core.api.DocumentRef; 023 024/** 025 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 026 */ 027@Operation(id = LockDocument.ID, category = Constants.CAT_DOCUMENT, label = "Lock", description = "Lock the input document for the current user. Returns back the locked document.") 028public class LockDocument { 029 030 public static final String ID = "Document.Lock"; 031 032 @Context 033 protected CoreSession session; 034 035 /** @deprecated unused */ 036 @Deprecated 037 @Param(name = "owner", required = false) 038 protected String owner; 039 040 @OperationMethod(collector = DocumentModelCollector.class) 041 public DocumentModel run(DocumentRef doc) { 042 session.setLock(doc); 043 return session.getDocument(doc); 044 } 045 046 @OperationMethod(collector = DocumentModelCollector.class) 047 public DocumentModel run(DocumentModel doc) { 048 session.setLock(doc.getRef()); 049 return session.getDocument(doc.getRef()); 050 } 051 052}