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.collectors.DocumentModelCollector; 019import org.nuxeo.ecm.core.api.CoreSession; 020import org.nuxeo.ecm.core.api.DocumentModel; 021import org.nuxeo.ecm.core.api.DocumentRef; 022 023/** 024 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 025 */ 026@Operation(id = DeleteDocument.ID, category = Constants.CAT_DOCUMENT, label = "Delete", description = "Delete the input document. The previous context input will be restored for the next operation.") 027public class DeleteDocument { 028 029 public static final String ID = "Document.Delete"; 030 031 @Context 032 protected CoreSession session; 033 034 @OperationMethod(collector = DocumentModelCollector.class) 035 public DocumentModel run(DocumentRef doc) { 036 // if (soft) { 037 // //TODO impl safe delete 038 // throw new UnsupportedOperationException("Safe delete not yet 039 // implemented"); 040 // } 041 session.removeDocument(doc); 042 // TODO ctx.pop 043 return null; 044 } 045 046 @OperationMethod(collector = DocumentModelCollector.class) 047 public DocumentModel run(DocumentModel doc) { 048 // if (soft) { 049 // //TODO impl safe delete 050 // throw new UnsupportedOperationException("Safe delete not yet 051 // implemented"); 052 // } 053 session.removeDocument(doc.getRef()); 054 // TODO ctx.pop 055 return null; 056 } 057 058}