001/*
002 * (C) Copyright 2012-2014 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl-2.1.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *      Vladimir Pasquier <vpasquier@nuxeo.com>
016 *      Thibaud Arguillere <targuillere@nuxeo.com>
017 */
018package org.nuxeo.ecm.platform.tag.operations;
019
020import org.nuxeo.ecm.automation.core.Constants;
021import org.nuxeo.ecm.automation.core.annotations.Context;
022import org.nuxeo.ecm.automation.core.annotations.Operation;
023import org.nuxeo.ecm.automation.core.annotations.OperationMethod;
024import org.nuxeo.ecm.automation.core.collectors.DocumentModelCollector;
025import org.nuxeo.ecm.core.api.CoreSession;
026import org.nuxeo.ecm.core.api.DocumentModel;
027import org.nuxeo.ecm.platform.tag.TagService;
028
029/**
030 * @since 7.1 Remove document tags.
031 */
032@Operation(id = RemoveDocumentTags.ID, category = Constants.CAT_SERVICES, label = "Remove All Document Tags", description = "Remove all document tags.", since = "7.1", addToStudio = true)
033public class RemoveDocumentTags {
034
035    public static final String ID = "Services.RemoveDocumentTags";
036
037    @Context
038    protected TagService tagService;
039
040    @Context
041    protected CoreSession session;
042
043    @OperationMethod(collector = DocumentModelCollector.class)
044    public DocumentModel run(DocumentModel document) {
045        tagService.removeTags(session, document.getId());
046        return document;
047    }
048}