001/* 002 * (C) Copyright 2012 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.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 * Antoine Taillefer <ataillefer@nuxeo.com> 016 */ 017package org.nuxeo.drive.operations.test; 018 019import org.nuxeo.drive.service.FileSystemItemAdapterService; 020import org.nuxeo.drive.service.VersioningFileSystemItemFactory; 021import org.nuxeo.drive.service.impl.DefaultFileSystemItemFactory; 022import org.nuxeo.drive.service.impl.FileSystemItemAdapterServiceImpl; 023import org.nuxeo.ecm.automation.core.Constants; 024import org.nuxeo.ecm.automation.core.annotations.Operation; 025import org.nuxeo.ecm.automation.core.annotations.OperationMethod; 026import org.nuxeo.ecm.automation.core.annotations.Param; 027import org.nuxeo.ecm.core.api.VersioningOption; 028import org.nuxeo.runtime.api.Framework; 029 030/** 031 * Sets versioning options on the {@link DefaultFileSystemItemFactory}: 032 * <ul> 033 * <li>delay (default: 1 hour)</li> 034 * <li>option (default: MINOR)</li> 035 * </ul> 036 * 037 * @author Antoine Taillefer 038 */ 039@Operation(id = NuxeoDriveSetVersioningOptions.ID, category = Constants.CAT_SERVICES, label = "Nuxeo Drive: Set versioning options") 040public class NuxeoDriveSetVersioningOptions { 041 042 public static final String ID = "NuxeoDrive.SetVersioningOptions"; 043 044 @Param(name = "delay", required = false) 045 protected String delay; 046 047 @Param(name = "option", required = false) 048 protected String option; 049 050 @OperationMethod 051 public void run() { 052 NuxeoDriveIntegrationTestsHelper.checkOperationAllowed(); 053 FileSystemItemAdapterService fileSystemItemAdapterService = Framework.getLocalService(FileSystemItemAdapterService.class); 054 VersioningFileSystemItemFactory defaultFileSystemItemFactory = (VersioningFileSystemItemFactory) ((FileSystemItemAdapterServiceImpl) fileSystemItemAdapterService).getFileSystemItemFactory("defaultFileSystemItemFactory"); 055 if (delay != null) { 056 defaultFileSystemItemFactory.setVersioningDelay(Double.parseDouble(delay)); 057 } 058 if (option != null) { 059 defaultFileSystemItemFactory.setVersioningOption(VersioningOption.valueOf(option)); 060 } 061 } 062}