001/* 002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Antoine Taillefer <ataillefer@nuxeo.com> 018 */ 019package org.nuxeo.drive.operations.test; 020 021import org.nuxeo.drive.service.FileSystemItemAdapterService; 022import org.nuxeo.drive.service.VersioningFileSystemItemFactory; 023import org.nuxeo.drive.service.impl.DefaultFileSystemItemFactory; 024import org.nuxeo.drive.service.impl.FileSystemItemAdapterServiceImpl; 025import org.nuxeo.ecm.automation.core.Constants; 026import org.nuxeo.ecm.automation.core.annotations.Operation; 027import org.nuxeo.ecm.automation.core.annotations.OperationMethod; 028import org.nuxeo.ecm.automation.core.annotations.Param; 029import org.nuxeo.ecm.core.api.VersioningOption; 030import org.nuxeo.runtime.api.Framework; 031 032/** 033 * Sets versioning options on the {@link DefaultFileSystemItemFactory}: 034 * <ul> 035 * <li>delay (default: 1 hour)</li> 036 * <li>option (default: MINOR)</li> 037 * </ul> 038 * 039 * @author Antoine Taillefer 040 */ 041@Operation(id = NuxeoDriveSetVersioningOptions.ID, category = Constants.CAT_SERVICES, label = "Nuxeo Drive: Set versioning options") 042public class NuxeoDriveSetVersioningOptions { 043 044 public static final String ID = "NuxeoDrive.SetVersioningOptions"; 045 046 @Param(name = "delay", required = false) 047 protected String delay; 048 049 @Param(name = "option", required = false) 050 protected String option; 051 052 @OperationMethod 053 public void run() { 054 NuxeoDriveIntegrationTestsHelper.checkOperationAllowed(); 055 FileSystemItemAdapterService fileSystemItemAdapterService = Framework.getLocalService(FileSystemItemAdapterService.class); 056 VersioningFileSystemItemFactory defaultFileSystemItemFactory = (VersioningFileSystemItemFactory) ((FileSystemItemAdapterServiceImpl) fileSystemItemAdapterService).getFileSystemItemFactory("defaultFileSystemItemFactory"); 057 if (delay != null) { 058 defaultFileSystemItemFactory.setVersioningDelay(Double.parseDouble(delay)); 059 } 060 if (option != null) { 061 defaultFileSystemItemFactory.setVersioningOption(VersioningOption.valueOf(option)); 062 } 063 } 064}