/// <summary> /// Initializes a new instance of the <see cref="DescendantsCrawler"/> class. /// </summary> /// <param name="queue">Sync Event Queue.</param> /// <param name="remoteFolder">Remote folder.</param> /// <param name="localFolder">Local folder.</param> /// <param name="storage">Meta data storage.</param> /// <param name="filter">Aggregated filter.</param> /// <param name="activityListener">Activity listner.</param> public DescendantsCrawler( ISyncEventQueue queue, IFolder remoteFolder, IDirectoryInfo localFolder, IMetaDataStorage storage, IFilterAggregator filter, IActivityListener activityListener, IIgnoredEntitiesStorage ignoredStorage) : base(queue) { if (remoteFolder == null) { throw new ArgumentNullException("remoteFolder"); } if (localFolder == null) { throw new ArgumentNullException("localFolder"); } if (storage == null) { throw new ArgumentNullException("storage"); } if (filter == null) { throw new ArgumentNullException("filter"); } if (activityListener == null) { throw new ArgumentNullException("activityListener"); } this.activityListener = activityListener; this.treebuilder = new DescendantsTreeBuilder(storage, remoteFolder, localFolder, filter, ignoredStorage); this.eventGenerator = new CrawlEventGenerator(storage); this.notifier = new CrawlEventNotifier(queue); }
public void CreateMockObjects() { this.storageEngine = new DBreezeEngine(new DBreezeConfiguration { Storage = DBreezeConfiguration.eStorage.MEMORY }); this.localRootPath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); this.matcher = new PathMatcher(this.localRootPath, this.remoteRootPath); this.queue = new Mock <ISyncEventQueue>(); this.remoteFolder = MockOfIFolderUtil.CreateRemoteFolderMock(this.remoteRootId, this.remoteRootPath, this.remoteRootPath); this.remoteFolder.SetupDescendants(); this.localFolder = new Mock <IDirectoryInfo>(); this.localFolder.Setup(f => f.FullName).Returns(this.localRootPath); this.localFolder.Setup(f => f.Exists).Returns(true); this.localFolder.Setup(f => f.IsExtendedAttributeAvailable()).Returns(true); this.localFolder.SetupGuid(this.rootGuid); this.localFolder.Setup(f => f.LastWriteTimeUtc).Returns(this.lastLocalWriteTime); this.fsFactory = new Mock <IFileSystemInfoFactory>(); this.fsFactory.AddIDirectoryInfo(this.localFolder.Object); this.mappedRootObject = new MappedObject( this.remoteRootPath, this.remoteRootId, MappedObjectType.Folder, null, "changeToken") { Guid = this.rootGuid, LastLocalWriteTimeUtc = this.lastLocalWriteTime }; this.storage = new MetaDataStorage(this.storageEngine, this.matcher); this.storage.SaveMappedObject(this.mappedRootObject); this.filter = MockOfIFilterAggregatorUtil.CreateFilterAggregator().Object; this.listener = new Mock <IActivityListener>(); }
public CycleDetector(IMetaDataStorage storage) { if (storage == null) { throw new ArgumentNullException("storage"); } }
/// <summary> /// Analyse the situation of the actual event in combination with the meta data storage. /// </summary> /// <param name="storage">Meta data storage.</param> /// <param name="actualEvent">Actual event.</param> /// <returns>The detected local situation.</returns> public SituationType Analyse(IMetaDataStorage storage, AbstractFolderEvent actualEvent) { SituationType type = this.DoAnalyse(storage, actualEvent); Logger.Debug(string.Format("Local Situation is: {0}", type)); return(type); }
/// <summary> /// Initializes a new instance of the <see cref="CmisSync.Lib.Consumer.SituationSolver.RemoteObjectDeleted"/> class. /// </summary> /// <param name="session">Cmis session.</param> /// <param name="storage">Meta data storage.</param> public RemoteObjectDeleted(ISession session, IMetaDataStorage storage, IFilterAggregator filters) : base(session, storage) { if (filters == null) { throw new ArgumentNullException("filters"); } this.filters = filters; }
/// <summary> /// Initializes a new instance of the <see cref="ContentChanges"/> class. /// </summary> /// <param name="session">Cmis Session.</param> /// <param name="storage">Meta Data Storage.</param> /// <param name="queue">Event Queue.</param> /// <param name="maxNumberOfContentChanges">Max number of content changes.</param> /// <param name="isPropertyChangesSupported">If set to <c>true</c> is property changes supported.</param> public ContentChanges( ISession session, IMetaDataStorage storage, ISyncEventQueue queue, int maxNumberOfContentChanges = 100, bool isPropertyChangesSupported = false) : base(queue) { if (session == null) { throw new ArgumentNullException("session"); } if (storage == null) { throw new ArgumentNullException("storage"); } if (maxNumberOfContentChanges <= 1) { throw new ArgumentException("MaxNumberOfContentChanges must be greater then one", "maxNumberOfContentChanges"); } this.session = session; this.storage = storage; this.maxNumberOfContentChanges = maxNumberOfContentChanges; this.isPropertyChangesSupported = isPropertyChangesSupported; }
/// <summary> /// Initializes a new instance of the /// <see cref="CmisSync.Lib.Consumer.SituationSolver.LocalObjectMovedRemoteObjectMoved"/> class. /// </summary> /// <param name="session">Cmis Session.</param> /// <param name="storage">Meta data storage.</param> /// <param name="isServerAbleToUpdateModificationDate">If set to <c>true</c> the server is able to update modification date.</param> public LocalObjectMovedRemoteObjectMoved( ISession session, IMetaDataStorage storage) : base( session, storage) { }
/// <summary> /// Initializes a new instance of the /// <see cref="CreatedChangedDeletedFileSystemEventHandler"/> class. /// </summary> /// <param name="queue">Sync event queue.</param> /// <param name="storage">Meta data storage.</param> /// <param name="fsFactory">File system info factory.</param> /// <param name="threshold">Delay after which a deleted event is passed to the queue.</param> public CreatedChangedDeletedFileSystemEventHandler( ISyncEventQueue queue, IMetaDataStorage storage, IFileSystemInfoFactory fsFactory = null, long threshold = 100) { if (queue == null) { throw new ArgumentNullException("Given queue is null"); } if (storage == null) { throw new ArgumentNullException("Given storage is null"); } this.queue = queue; this.storage = storage; this.threshold = threshold; this.fsFactory = fsFactory ?? new FileSystemInfoFactory(); this.events = new List <Tuple <FileSystemEventArgs, Guid, DateTime, bool> >(); this.timer = new Timer(); this.timer.AutoReset = false; this.timer.Elapsed += (sender, e) => this.PopEventsFromList(); }
private string GetParentId(IFileSystemInfo fileInfo, IMetaDataStorage storage) { IDirectoryInfo parent = null; if (fileInfo is IDirectoryInfo) { IDirectoryInfo localDirInfo = fileInfo as IDirectoryInfo; parent = localDirInfo.Parent; } else { IFileInfo localFileInfo = fileInfo as IFileInfo; parent = localFileInfo.Directory; } try { Guid uuid; if (Guid.TryParse(parent.GetExtendedAttribute(MappedObject.ExtendedAttributeKey), out uuid)) { return(storage.GetObjectByGuid(uuid).RemoteObjectId); } } catch (IOException) { } IMappedObject mappedParent = storage.GetObjectByLocalPath(parent); return(mappedParent.RemoteObjectId); }
/// <summary> /// Initializes a new instance of the <see cref="CmisSync.Lib.Producer.Crawler.DescendantsTreeBuilder"/> class. /// </summary> /// <param name='storage'> /// The MetadataStorage. /// </param> /// <param name='remoteFolder'> /// Remote folder. /// </param> /// <param name='localFolder'> /// Local folder. /// </param> /// <param name='filter'> /// Aggregated Filters. /// </param> /// <exception cref='ArgumentNullException'> /// <attribution license="cc4" from="Microsoft" modified="false" /><para>The exception that is thrown when a /// null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument. </para> /// </exception> public DescendantsTreeBuilder(IMetaDataStorage storage, IFolder remoteFolder, IDirectoryInfo localFolder, IFilterAggregator filter) { if (remoteFolder == null) { throw new ArgumentNullException("Given remoteFolder is null"); } if (localFolder == null) { throw new ArgumentNullException("Given localFolder is null"); } if (storage == null) { throw new ArgumentNullException("Given storage is null"); } if (filter == null) { throw new ArgumentNullException("Given filter is null"); } this.storage = storage; this.remoteFolder = remoteFolder; this.localFolder = localFolder; this.filter = filter; }
/// <summary> /// Initializes a new instance of the <see cref="CmisSync.Lib.Producer.Crawler.DescendantsTreeBuilder"/> class. /// </summary> /// <param name='storage'> /// The MetadataStorage. /// </param> /// <param name='remoteFolder'> /// Remote folder. /// </param> /// <param name='localFolder'> /// Local folder. /// </param> /// <param name='filter'> /// Aggregated Filters. /// </param> /// <exception cref='ArgumentNullException'> /// <attribution license="cc4" from="Microsoft" modified="false" /><para>The exception that is thrown when a /// null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument. </para> /// </exception> public DescendantsTreeBuilder( IMetaDataStorage storage, IFolder remoteFolder, IDirectoryInfo localFolder, IFilterAggregator filter, IIgnoredEntitiesStorage ignoredStorage) { if (remoteFolder == null) { throw new ArgumentNullException("remoteFolder"); } if (localFolder == null) { throw new ArgumentNullException("localFolder"); } if (storage == null) { throw new ArgumentNullException("storage"); } if (filter == null) { throw new ArgumentNullException("filter"); } if (ignoredStorage == null) { throw new ArgumentNullException("ignoredStorage"); } this.storage = storage; this.remoteFolder = remoteFolder; this.localFolder = localFolder; this.filter = filter; this.matcher = new PathMatcher(localFolder.FullName, remoteFolder.Path); this.ignoredStorage = ignoredStorage; }
private string GetParentId(IFileSystemInfo fileInfo, IMetaDataStorage storage) { IDirectoryInfo parent = null; if (fileInfo is IDirectoryInfo) { IDirectoryInfo localDirInfo = fileInfo as IDirectoryInfo; parent = localDirInfo.Parent; } else { IFileInfo localFileInfo = fileInfo as IFileInfo; parent = localFileInfo.Directory; } try { Guid?uuid = parent.Uuid; if (uuid != null) { return(storage.GetObjectByGuid((Guid)uuid).RemoteObjectId); } } catch (IOException) { } IMappedObject mappedParent = storage.GetObjectByLocalPath(parent); return(mappedParent.RemoteObjectId); }
private bool IsChangeEventAHintForMove(IMetaDataStorage storage, AbstractFolderEvent actualEvent) { if (actualEvent is FolderEvent) { var folderEvent = actualEvent as FolderEvent; var storedFolder = storage.GetObjectByRemoteId(folderEvent.RemoteFolder.Id); if (storedFolder != null) { if (storedFolder.ParentId != folderEvent.RemoteFolder.ParentId) { return(true); } } } else if (actualEvent is FileEvent) { var fileEvent = actualEvent as FileEvent; if (fileEvent.RemoteFile.Parents == null || fileEvent.RemoteFile.Parents.Count == 0) { return(false); } var storedFile = storage.GetObjectByRemoteId(fileEvent.RemoteFile.Id); if (storedFile != null && storedFile.ParentId != fileEvent.RemoteFile.Parents[0].Id) { return(true); } } return(false); }
public LocalObjectRenamedOrMovedRemoteObjectDeleted( ISession session, IMetaDataStorage storage, ActiveActivitiesManager manager, ISolver secondSolver = null) : base(session, storage) { this.secondSolver = secondSolver ?? new LocalObjectAdded(session, storage, manager); }
public RemoteEventGenerator(IMetaDataStorage storage) { if (storage == null) { throw new ArgumentNullException("storage"); } this.storage = storage; }
/// <summary> /// Initializes a new instance of the <see cref="CmisSync.Lib.Filter.IgnoreAlreadyHandledFsEventsFilter"/> class. /// </summary> /// <param name="storage">Storage instance.</param> /// <param name="fsFactory">Fs factory.</param> public IgnoreAlreadyHandledFsEventsFilter(IMetaDataStorage storage, IFileSystemInfoFactory fsFactory = null) { if (storage == null) { throw new ArgumentNullException("storage"); } this.storage = storage; this.fsFactory = fsFactory ?? new FileSystemInfoFactory(); }
private void RunSuccessfulLoginEvent(IMetaDataStorage storage, ISyncEventManager manager, ActivityListenerAggregator listener, bool changeEventSupported = false, string id = "i", string token = "t") { var e = CreateNewSessionEvent(changeEventSupported, id, token); var handler = this.CreateStrategyInitializer(storage, manager, listener); Assert.True(handler.Handle(e)); }
public LocalObjectRenamedOrMovedRemoteObjectDeleted( ISession session, IMetaDataStorage storage, IFileTransmissionStorage transmissionStorage, TransmissionManager manager, ISolver secondSolver = null) : base(session, storage) { this.secondSolver = secondSolver ?? new LocalObjectAdded(session, storage, transmissionStorage, manager); }
/// <summary> /// Initializes a new instance of the <see cref="RemoteObjectMovedOrRenamedAccumulator"/> class. /// </summary> /// <param name="queue">Sync event queue.</param> /// <param name="storage">Meta data storage.</param> /// <param name="fsFactory">FileSystemInfo factory.</param> public RemoteObjectMovedOrRenamedAccumulator(ISyncEventQueue queue, IMetaDataStorage storage, IFileSystemInfoFactory fsFactory = null) : base(queue) { if (storage == null) { throw new ArgumentNullException("storage"); } this.storage = storage; this.fsFactory = fsFactory == null ? new FileSystemInfoFactory() : fsFactory; }
public HandlerMockWithoutTimerAction( ISyncEventQueue queue, IMetaDataStorage storage, IFileSystemInfoFactory fsFactory) : base(queue, storage, fsFactory, 10) { this.timer.Dispose(); this.timer = new Timer(); this.timer.AutoReset = false; }
/// <summary> /// Initializes a new instance of the /// <see cref="CmisSync.Lib.Consumer.SituationSolver.LocalObjectMovedRemoteObjectMoved"/> class. /// </summary> /// <param name="session">Cmis Session.</param> /// <param name="storage">Meta data storage.</param> /// <param name="isServerAbleToUpdateModificationDate">If set to <c>true</c> the server is able to update modification date.</param> public LocalObjectMovedRemoteObjectMoved( ISession session, IMetaDataStorage storage, bool isServerAbleToUpdateModificationDate) : base( session, storage, isServerAbleToUpdateModificationDate) { }
/// <summary> /// Initializes a new instance of the <see cref="EventManagerInitializer"/> class. /// </summary> /// <param name='queue'>The SyncEventQueue.</param> /// <param name='storage'>Storage for Metadata.</param> /// <param name='fileTransmissionStorage'>Storage for file transmissions.</param> /// <param name='ignoredStorage'>Storage for ignored entities.</param> /// <param name='repoInfo'>Repo info.</param> /// <param name='filter'>Filter aggregation.</param> /// <param name='activityListner'>Listener for Sync activities.</param> /// <param name='fsFactory'>File system factory.</param> /// <exception cref='ArgumentNullException'> /// Is thrown when an argument passed to a method is invalid because it is <see langword="null" /> . /// </exception> public EventManagerInitializer( ISyncEventQueue queue, IMetaDataStorage storage, IFileTransmissionStorage fileTransmissionStorage, IIgnoredEntitiesStorage ignoredStorage, RepoInfo repoInfo, IFilterAggregator filter, ActivityListenerAggregator activityListener, IFileSystemInfoFactory fsFactory = null) : base(queue) { if (storage == null) { throw new ArgumentNullException("storage"); } if (fileTransmissionStorage == null) { throw new ArgumentNullException("fileTransmissionStorage"); } if (repoInfo == null) { throw new ArgumentNullException("repoInfo"); } if (filter == null) { throw new ArgumentNullException("filter"); } if (activityListener == null) { throw new ArgumentNullException("activityListener"); } if (ignoredStorage == null) { throw new ArgumentNullException("ignoredStorage", "Given storage for ignored entries is null"); } if (fsFactory == null) { this.fileSystemFactory = new FileSystemInfoFactory(); } else { this.fileSystemFactory = fsFactory; } this.filter = filter; this.repoInfo = repoInfo; this.storage = storage; this.ignoredStorage = ignoredStorage; this.fileTransmissionStorage = fileTransmissionStorage; this.activityListener = activityListener; }
/// <summary> /// Initializes a new instance of the /// <see cref="CmisSync.Lib.Consumer.SituationSolver.LocalObjectRenamedRemoteObjectRenamed"/> class. /// </summary> /// <param name="session">Cmis session.</param> /// <param name="storage">Meta data storage.</param> /// <param name="changeChangeSolver">Fallback solver for local and remote change situation after renaming is done.</param> public LocalObjectRenamedRemoteObjectRenamed( ISession session, IMetaDataStorage storage, ISolver changeChangeSolver) : base(session, storage) { if (changeChangeSolver == null) { throw new ArgumentNullException("changeChangeSolver", "Given solver for the situation of local and remote object changed is null"); } this.changeChangeSolver = changeChangeSolver; }
/// <summary> /// Initializes a new instance of the <see cref="SyncMechanism"/> class. /// </summary> /// <param name="localSituation">Local situation.</param> /// <param name="remoteSituation">Remote situation.</param> /// <param name="queue">Sync event queue.</param> /// <param name="session">CMIS Session.</param> /// <param name="storage">Meta data storage.</param> /// <param name="transmissionStorage">File transmission storage.</param> /// <param name="activityListener">Active sync progress listener.</param> /// <param name="filters">Ignore filter.</param> /// <param name="solver">Solver for custom solver matrix.</param> public SyncMechanism( ISituationDetection <AbstractFolderEvent> localSituation, ISituationDetection <AbstractFolderEvent> remoteSituation, ISyncEventQueue queue, ISession session, IMetaDataStorage storage, IFileTransmissionStorage transmissionStorage, ActivityListenerAggregator activityListener, IFilterAggregator filters, ISolver[,] solver = null) : base(queue) { if (session == null) { throw new ArgumentNullException("session"); } if (storage == null) { throw new ArgumentNullException("storage"); } if (transmissionStorage == null) { throw new ArgumentNullException("transmissionStorage"); } if (localSituation == null) { throw new ArgumentNullException("localSituation"); } if (remoteSituation == null) { throw new ArgumentNullException("remoteSituation"); } if (activityListener == null) { throw new ArgumentNullException("activityListener"); } if (filters == null) { throw new ArgumentNullException("filters"); } this.session = session; this.storage = storage; this.transmissionStorage = transmissionStorage; this.LocalSituation = localSituation; this.RemoteSituation = remoteSituation; this.activityListener = activityListener; this.filters = filters; this.Solver = solver == null?this.CreateSolver() : solver; }
/// <summary> /// Analyse the specified actual event. /// </summary> /// <param name="storage">Storage of saved MappedObjects.</param> /// <param name="actualEvent">Actual event.</param> /// <returns>The detected situation type</returns> public SituationType Analyse(IMetaDataStorage storage, AbstractFolderEvent actualEvent) { if (actualEvent.Remote == MetaDataChangeType.NONE && this.IsRemoteObjectDifferentToLastSync(storage, actualEvent)) { actualEvent.Remote = MetaDataChangeType.CHANGED; } SituationType type = this.DoAnalyse(storage, actualEvent); return(type); }
/// <summary> /// Initializes a new instance of the /// <see cref="CmisSync.Lib.Filter.IgnoreAlreadyHandledContentChangeEventsFilter"/> class. /// </summary> /// <param name="storage">Storage instance.</param> /// <param name="session">Session instance.</param> public IgnoreAlreadyHandledContentChangeEventsFilter(IMetaDataStorage storage, ISession session) { if (storage == null) { throw new ArgumentNullException("storage"); } if (session == null) { throw new ArgumentNullException("session"); } this.storage = storage; this.session = session; }
/// <summary> /// Initializes a new instance of the <see cref="CmisSync.Lib.Consumer.SituationSolver.LocalObjectChanged"/> class. /// </summary> /// <param name="session">Cmis session.</param> /// <param name="storage">Meta data storage.</param> /// <param name="transmissionManager">Transmission manager.</param> public LocalObjectChanged( ISession session, IMetaDataStorage storage, ActiveActivitiesManager transmissionManager) : base(session, storage) { if (transmissionManager == null) { throw new ArgumentNullException("Given transmission manager is null"); } this.transmissionManager = transmissionManager; }
/// <summary> /// Initializes a new instance of the <see cref="CmisSync.Lib.Consumer.SituationSolver.PWC.AbstractEnhancedSolverWithPWC"/> class. /// </summary> /// <param name="session">Cmis Session.</param> /// <param name="storage">Meta Data Storage.</param> /// <param name="transmissionStorage">File Transmission Storage.</param> public AbstractEnhancedSolverWithPWC( ISession session, IMetaDataStorage storage, IFileTransmissionStorage transmissionStorage) : base(session, storage, transmissionStorage) { if (transmissionStorage == null) { throw new ArgumentNullException("Given transmission storage is null"); } if (!session.ArePrivateWorkingCopySupported()) { throw new ArgumentException("Given session does not support private working copies"); } }
private SituationType DoAnalyse(IMetaDataStorage storage, AbstractFolderEvent actualEvent) { IFileSystemInfo localPath = actualEvent is FolderEvent ? (IFileSystemInfo)(actualEvent as FolderEvent).LocalFolder : (IFileSystemInfo)(actualEvent is FileEvent ? (actualEvent as FileEvent).LocalFile : null); switch (actualEvent.Local) { case MetaDataChangeType.CREATED: return(SituationType.ADDED); case MetaDataChangeType.DELETED: return(SituationType.REMOVED); case MetaDataChangeType.MOVED: try { Guid?guid = localPath.Uuid; var obj = storage.GetObjectByGuid((Guid)guid); var parent = storage.GetObjectByRemoteId(obj.ParentId); Guid?parentGuid = (localPath is IFileInfo) ? (localPath as IFileInfo).Directory.Uuid : (localPath as IDirectoryInfo).Parent.Uuid; if (parent.Guid == (Guid)parentGuid) { return(SituationType.RENAMED); } } catch (Exception) { } return(SituationType.MOVED); case MetaDataChangeType.CHANGED: if (storage.GetObjectByLocalPath(localPath) == null) { Guid?guid = localPath.Uuid; if (guid != null && storage.GetObjectByGuid((Guid)guid) != null) { return(SituationType.RENAMED); } } return(SituationType.CHANGED); case MetaDataChangeType.NONE: if (actualEvent is FileEvent && (actualEvent as FileEvent).LocalContent != ContentChangeType.NONE) { return(SituationType.CHANGED); } else { return(SituationType.NOCHANGE); } default: return(SituationType.NOCHANGE); } }
public LocalObjectChangedRemoteObjectRenamed( ISession session, IMetaDataStorage storage, LocalObjectChangedRemoteObjectChanged changeSolver) : base(session, storage) { if (changeSolver == null) { throw new ArgumentNullException("Given solver for the situation of local and remote changes is null"); } this.changeChangeSolver = changeSolver; }
public LocalEventGenerator(IMetaDataStorage storage, IFileSystemInfoFactory fsFactory = null) { if (storage == null) { throw new ArgumentNullException("storage"); } this.storage = storage; if (fsFactory == null) { this.fsFactory = new FileSystemInfoFactory(); } else { this.fsFactory = fsFactory; } }
/// <summary> /// Initializes a new instance of the <see cref="CmisSync.Lib.Consumer.SituationSolver.LocalObjectChanged"/> class. /// </summary> /// <param name="session">Cmis session.</param> /// <param name="storage">Meta data storage.</param> /// <param name="transmissionManager">Transmission manager.</param> public LocalObjectChanged( ISession session, IMetaDataStorage storage, IFileTransmissionStorage transmissionStorage, ITransmissionManager transmissionManager) : base(session, storage, transmissionStorage) { if (transmissionManager == null) { throw new ArgumentNullException("transmissionManager"); } this.transmissionManager = transmissionManager; }
/// <summary> /// Initializes a new instance of the <see cref="CmisSync.Lib.SelectiveIgnore.IgnoredEntitiesStorage"/> class. /// </summary> /// <param name="collection">Ignored entries collection.</param> /// <param name="storage">Meta data storage.</param> public IgnoredEntitiesStorage(IIgnoredEntitiesCollection collection, IMetaDataStorage storage) { if (collection == null) { throw new ArgumentNullException("collection"); } if (storage == null) { throw new ArgumentNullException("storage"); } this.collection = collection; this.storage = storage; }
/// <summary> /// Gets the remote identifier by trying to read the Uuid of the given directory. If this fails or returns null, /// the local path is used to request the remote object id from the storage. /// </summary> /// <returns>The stored remote identifier, or null if there is no entry found.</returns> /// <param name="storage">Meta data storage instance.</param> /// <param name="info">File system item info.</param> public static string GetRemoteId(this IMetaDataStorage storage, IFileSystemInfo info) { IMappedObject mappedObject = storage.GetObject(info); if (mappedObject != null) { return(mappedObject.RemoteObjectId); } else { return(null); } }
/// <summary> /// Initializes a new instance of the <see cref="CmisSync.Lib.Sync.Strategy.ContentChangeEventTransformer"/> class. /// </summary> /// <param name='queue'> /// The ISyncEventQueue. /// </param> /// <param name='storage'> /// The MetaDataStorage. /// </param> /// <param name='fsFactory'> /// Fs factory can be null. /// </param> /// <exception cref='ArgumentNullException'> /// Is thrown when an argument passed to a method is invalid because it is <see langword="null" /> . /// </exception> public ContentChangeEventTransformer(ISyncEventQueue queue, IMetaDataStorage storage, IFileSystemInfoFactory fsFactory = null) : base(queue) { if (storage == null) { throw new ArgumentNullException("storage"); } this.storage = storage; if (fsFactory == null) { this.fsFactory = new FileSystemInfoFactory(); } else { this.fsFactory = fsFactory; } }
/// <summary> /// Initializes a new instance of the <see cref="RemoteObjectFetcher"/> class. /// Fetches remote CMIS Objects and adds them to the handled events. /// </summary> /// <param name="session">Session to be used.</param> /// <param name="storage">Storage to look for mapped objects.</param> public RemoteObjectFetcher(ISession session, IMetaDataStorage storage) { if (session == null) { throw new ArgumentNullException("session"); } if (storage == null) { throw new ArgumentNullException("storage"); } this.session = session; this.storage = storage; this.operationContext = OperationContextFactory.CreateNonCachingPathIncludingContext(this.session); }
/// <summary> /// Initializes a new instance of the /// <see cref="CmisSync.Lib.Consumer.SituationSolver.LocalObjectChangedRemoteObjectChanged"/> class. /// </summary> /// <param name="session">Cmis session.</param> /// <param name="storage">Meta data storage.</param> /// <param name="transmissionStorage">Transmission storage.</param> /// <param name="transmissionManager">Transmission manager.</param> /// <param name="fsFactory">File system factory.</param> public LocalObjectChangedRemoteObjectChanged( ISession session, IMetaDataStorage storage, IFileTransmissionStorage transmissionStorage, ITransmissionManager transmissionManager, IFileSystemInfoFactory fsFactory = null) : base(session, storage, transmissionStorage) { if (transmissionManager == null) { throw new ArgumentNullException("transmissionManager"); } this.transmissionManager = transmissionManager; this.fsFactory = fsFactory ?? new FileSystemInfoFactory(); }
/// <summary> /// Initializes a new instance of the <see cref="SyncMechanism"/> class. /// </summary> /// <param name="localSituation">Local situation.</param> /// <param name="remoteSituation">Remote situation.</param> /// <param name="queue">Sync event queue.</param> /// <param name="session">CMIS Session.</param> /// <param name="storage">Meta data storage.</param> /// <param name="activityListener">Active sync progress listener.</param> /// <param name="solver">Solver for custom solver matrix.</param> /// <param name="isServerAbleToUpdateModificationDate">Enables the modification date sync feature.</param> public SyncMechanism( ISituationDetection <AbstractFolderEvent> localSituation, ISituationDetection <AbstractFolderEvent> remoteSituation, ISyncEventQueue queue, ISession session, IMetaDataStorage storage, ActivityListenerAggregator activityListener, IFilterAggregator filters, ISolver[,] solver = null, bool isServerAbleToUpdateModificationDate = false) : base(queue) { if (session == null) { throw new ArgumentNullException("Given session is null"); } if (storage == null) { throw new ArgumentNullException("Given storage is null"); } if (localSituation == null) { throw new ArgumentNullException("Given local situation detection is null"); } if (remoteSituation == null) { throw new ArgumentNullException("Given remote situation detection is null"); } if (activityListener == null) { throw new ArgumentNullException("Given activity listener is null"); } if (filters == null) { throw new ArgumentNullException("Given filter aggregator is null"); } this.session = session; this.storage = storage; this.LocalSituation = localSituation; this.RemoteSituation = remoteSituation; this.activityListener = activityListener; this.isServerAbleToUpdateModificationDate = isServerAbleToUpdateModificationDate; this.filters = filters; this.Solver = solver == null?this.CreateSolver() : solver; }
/// <summary> /// Initializes a new instance of the <see cref="CmisSync.Lib.Consumer.SituationSolver.RemoteObjectChanged"/> class. /// </summary> /// <param name="session">Cmis session.</param> /// <param name="storage">Meta data storage.</param> /// <param name="transmissonManager">Transmisson manager.</param> /// <param name="fsFactory">File System Factory.</param> public RemoteObjectChanged( ISession session, IMetaDataStorage storage, ActiveActivitiesManager transmissonManager, IFileSystemInfoFactory fsFactory = null) : base(session, storage) { if (transmissonManager == null) { throw new ArgumentNullException("Given transmission manager is null"); } this.transmissonManager = transmissonManager; this.fsFactory = fsFactory ?? new FileSystemInfoFactory(); }
/// <summary> /// Initializes a new instance of the /// <see cref="CmisSync.Lib.Filter.IgnoreAlreadyHandledContentChangeEventsFilter"/> class. /// </summary> /// <param name="storage">Storage instance.</param> /// <param name="session">Session instance.</param> public IgnoreAlreadyHandledContentChangeEventsFilter(IMetaDataStorage storage, ISession session) { if (storage == null) { throw new ArgumentNullException("Given storage instance is null"); } if (session == null) { throw new ArgumentNullException("Given session instance is null"); } this.storage = storage; this.session = session; }
/// <summary> /// Initializes a new instance of the <see cref="SyncMechanism"/> class. /// </summary> /// <param name="localSituation">Local situation.</param> /// <param name="remoteSituation">Remote situation.</param> /// <param name="queue">Sync event queue.</param> /// <param name="session">CMIS Session.</param> /// <param name="storage">Meta data storage.</param> /// <param name="transmissionStorage">File transmission storage.</param> /// <param name="activityListener">Active sync progress listener.</param> /// <param name="filters">Ignore filter.</param> /// <param name="solver">Solver for custom solver matrix.</param> public SyncMechanism( ISituationDetection<AbstractFolderEvent> localSituation, ISituationDetection<AbstractFolderEvent> remoteSituation, ISyncEventQueue queue, ISession session, IMetaDataStorage storage, IFileTransmissionStorage transmissionStorage, ActivityListenerAggregator activityListener, IFilterAggregator filters, ISolver[,] solver = null) : base(queue) { if (session == null) { throw new ArgumentNullException("session"); } if (storage == null) { throw new ArgumentNullException("storage"); } if (transmissionStorage == null) { throw new ArgumentNullException("transmissionStorage"); } if (localSituation == null) { throw new ArgumentNullException("localSituation"); } if (remoteSituation == null) { throw new ArgumentNullException("remoteSituation"); } if (activityListener == null) { throw new ArgumentNullException("activityListener"); } if (filters == null) { throw new ArgumentNullException("filters"); } this.session = session; this.storage = storage; this.transmissionStorage = transmissionStorage; this.LocalSituation = localSituation; this.RemoteSituation = remoteSituation; this.activityListener = activityListener; this.filters = filters; this.Solver = solver == null ? this.CreateSolver() : solver; }
public LocalObjectMovedRemoteObjectChanged( ISession session, IMetaDataStorage storage, ISolver renameChangeSolver, ISolver changeChangeSolver) : base(session, storage) { if (renameChangeSolver == null) { throw new ArgumentNullException("renameChangeSolver", "Given sitation solver for local rename and remote change is null"); } if (changeChangeSolver == null) { throw new ArgumentNullException("changeChangeSolver", "Given situation solver for local and remote changes is null"); } this.renameChangeSolver = renameChangeSolver; this.changeChangeSolver = changeChangeSolver; }
public LocalObjectChangedWithPWC( ISession session, IMetaDataStorage storage, IFileTransmissionStorage transmissionStorage, ITransmissionManager manager, ISolver folderOrFileContentUnchangedSolver) : base(session, storage, transmissionStorage) { if (folderOrFileContentUnchangedSolver == null) { throw new ArgumentNullException("folderOrFileContentUnchangedSolver", "Given solver for folder or unchanged file content situations is null"); } if (!session.ArePrivateWorkingCopySupported()) { throw new ArgumentException("The given session does not support private working copies", "session"); } this.folderOrFileContentUnchangedSolver = folderOrFileContentUnchangedSolver; this.transmissionManager = manager; }
/// <summary> /// Initializes a new instance of the <see cref="CmisSync.Lib.Consumer.SituationSolver.PWC.LocalObjectAddedWithPWC"/> class. /// </summary> /// <param name="session">Cmis session.</param> /// <param name="storage">Meta data storage.</param> /// <param name="transmissionStorage">Transmission storage.</param> /// <param name="manager">Active activities manager.</param> /// <param name="localFolderOrEmptyFileAddedSolver">Local folder or empty file added solver.</param> public LocalObjectAddedWithPWC( ISession session, IMetaDataStorage storage, IFileTransmissionStorage transmissionStorage, ITransmissionManager manager, ISolver localFolderOrEmptyFileAddedSolver) : base(session, storage, transmissionStorage) { if (localFolderOrEmptyFileAddedSolver == null) { throw new ArgumentNullException("localFolderOrEmptyFileAddedSolver", "Given solver for locally added folders is null"); } if (!session.ArePrivateWorkingCopySupported()) { throw new ArgumentException("Given session doesn't support private working copies", "session"); } this.folderOrEmptyFileAddedSolver = localFolderOrEmptyFileAddedSolver; this.transmissionManager = manager; }
/// <summary> /// Initializes a new instance of the /// <see cref="CmisSync.Lib.Consumer.SituationSolver.PWC.LocalObjectChangedRemoteObjectChangedWithPWC"/> class. /// </summary> /// <param name="session">Cmis session.</param> /// <param name="storage">Meta data storage.</param> /// <param name="transmissionStorage">Transmission storage.</param> /// <param name="manager">Transmission manager.</param> /// <param name="localObjectChangedRemoteObjectChangedFallbackSolver">Local object changed remote object changed fallback solver.</param> public LocalObjectChangedRemoteObjectChangedWithPWC( ISession session, IMetaDataStorage storage, IFileTransmissionStorage transmissionStorage, TransmissionManager manager, ISolver localObjectChangedRemoteObjectChangedFallbackSolver) : base(session, storage, transmissionStorage) { if (localObjectChangedRemoteObjectChangedFallbackSolver == null) { throw new ArgumentNullException("localObjectChangedRemoteObjectChangedFallbackSolver", "Given fallback solver is null"); } if (!session.ArePrivateWorkingCopySupported()) { throw new ArgumentException("Given session does not support pwc updates", "session"); } this.fallbackSolver = localObjectChangedRemoteObjectChangedFallbackSolver; this.transmissionManager = manager; }
/// <summary> /// Initializes a new instance of the <see cref="CmisSync.Lib.Consumer.SituationSolver.AbstractEnhancedSolver"/> class. /// </summary> /// <param name="session">Cmis Session.</param> /// <param name="storage">Meta Data Storage.</param> /// <param name="transmissionStorage">File Transmission Storage.</param> public AbstractEnhancedSolver( ISession session, IMetaDataStorage storage, IFileTransmissionStorage transmissionStorage = null) { this.Storage = storage; if (session == null) { throw new ArgumentNullException("session"); } if (storage == null) { throw new ArgumentNullException("storage"); } this.Session = session; this.Storage = storage; this.TransmissionStorage = transmissionStorage; this.ServerCanModifyDateTimes = this.Session.IsServerAbleToUpdateModificationDate(); }
/// <summary> /// Initializes a new instance of the <see cref="NetWatcher"/> class. /// Takes the given file system watcher and listens for events and passes them to the given queue /// </summary> /// <param name="watcher">File System Watcher.</param> /// <param name="queue">Queue for the occured events.</param> /// <param name="storage">Meta Data Storage to verify, if a deleted object is a file or folder.</param> /// <param name="fsFactory">File system info factory. If factory is null, the normal file system is used, otherwise the given factory.</param> public NetWatcher( FileSystemWatcher watcher, ISyncEventQueue queue, IMetaDataStorage storage, FileSystemInfoFactory fsFactory = null) { if (watcher == null) { throw new ArgumentNullException("watcher"); } if (string.IsNullOrEmpty(watcher.Path)) { throw new ArgumentException("The given watcher must contain a path, where it is listening"); } if (queue == null) { throw new ArgumentNullException("queue"); } if (storage == null) { throw new ArgumentNullException("storage"); } this.fsFactory = fsFactory ?? new FileSystemInfoFactory(); this.queue = queue; this.storage = storage; this.fileSystemWatcher = watcher; this.fileSystemWatcher.IncludeSubdirectories = true; this.fileSystemWatcher.Filter = "*"; this.fileSystemWatcher.InternalBufferSize = 4 * 1024 * 16; this.fileSystemWatcher.NotifyFilter = NotifyFilters.Size | NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.LastWrite | NotifyFilters.Security; this.createChangeDeleteHandler = new CreatedChangedDeletedFileSystemEventHandler(this.queue, this.storage, this.fsFactory); this.renamedHandler = new RenamedFileSystemEventHandler(this.queue, this.fsFactory); this.fileSystemWatcher.Created += new FileSystemEventHandler(this.createChangeDeleteHandler.Handle); this.fileSystemWatcher.Deleted += new FileSystemEventHandler(this.createChangeDeleteHandler.Handle); this.fileSystemWatcher.Changed += new FileSystemEventHandler(this.createChangeDeleteHandler.Handle); this.fileSystemWatcher.Renamed += new RenamedEventHandler(this.renamedHandler.Handle); }
/// <summary> /// Initializes a new instance of the /// <see cref="CreatedChangedDeletedFileSystemEventHandler"/> class. /// </summary> /// <param name="queue">Sync event queue.</param> /// <param name="storage">Meta data storage.</param> /// <param name="fsFactory">File system info factory.</param> /// <param name="threshold">Delay after which a deleted event is passed to the queue.</param> public CreatedChangedDeletedFileSystemEventHandler( ISyncEventQueue queue, IMetaDataStorage storage, IFileSystemInfoFactory fsFactory = null, long threshold = 100) { if (queue == null) { throw new ArgumentNullException("queue"); } if (storage == null) { throw new ArgumentNullException("storage"); } this.queue = queue; this.storage = storage; this.threshold = threshold; this.fsFactory = fsFactory ?? new FileSystemInfoFactory(); this.events = new List<Tuple<FileSystemEventArgs, Guid, DateTime, bool>>(); this.timer = new Timer(); this.timer.AutoReset = false; this.timer.Elapsed += (sender, e) => this.PopEventsFromList(); }
/// <summary> /// Initializes a new instance of the <see cref="CmisSync.Lib.Consumer.SituationSolver.RemoteObjectMoved"/> class. /// </summary> /// <param name="session">Cmis session.</param> /// <param name="storage">Meta data storage.</param> public RemoteObjectMoved(ISession session, IMetaDataStorage storage) : base(session, storage) { }
public MappedFile (MappedObjectData data, IMetaDataStorage storage, IFileSystemInfoFactory fsFactory = null) : base(data, storage, fsFactory) { }
/// <summary> /// Initializes a new instance of the /// <see cref="CmisSync.Lib.Consumer.SituationSolver.LocalObjectDeletedRemoteObjectDeleted"/> class. /// </summary> /// <param name="session">Cmis session.</param> /// <param name="storage">Meta data storage.</param> public LocalObjectDeletedRemoteObjectDeleted(ISession session, IMetaDataStorage storage) : base(session, storage) { }
public SolverClass( ISession session, IMetaDataStorage storage, IFileTransmissionStorage transmissionStorage = null) : base(session, storage, transmissionStorage) { }