001/** 002 * 003 */ 004 005package org.nuxeo.drive.operations; 006 007import org.nuxeo.drive.service.NuxeoDriveManager; 008import org.nuxeo.ecm.automation.core.Constants; 009import org.nuxeo.ecm.automation.core.annotations.Context; 010import org.nuxeo.ecm.automation.core.annotations.Operation; 011import org.nuxeo.ecm.automation.core.annotations.OperationMethod; 012import org.nuxeo.ecm.automation.core.annotations.Param; 013import org.nuxeo.ecm.core.api.CoreSession; 014import org.nuxeo.ecm.core.api.DocumentModel; 015import org.nuxeo.runtime.api.Framework; 016 017/** 018 * Make it possible for the client to add / remove synchronization roots. 019 */ 020@Operation(id = NuxeoDriveSetSynchronizationOperation.ID, category = Constants.CAT_SERVICES, label = "Nuxeo Drive: Register / Unregister Synchronization Root") 021public class NuxeoDriveSetSynchronizationOperation { 022 023 public static final String ID = "NuxeoDrive.SetSynchronization"; 024 025 @Context 026 protected CoreSession session; 027 028 @Param(name = "enable") 029 protected boolean enable; 030 031 @OperationMethod 032 public void run(DocumentModel doc) { 033 NuxeoDriveManager driveManager = Framework.getLocalService(NuxeoDriveManager.class); 034 if (enable) { 035 driveManager.registerSynchronizationRoot(session.getPrincipal(), doc, session); 036 } else { 037 driveManager.unregisterSynchronizationRoot(session.getPrincipal(), doc, session); 038 } 039 } 040 041}