コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CmisSync.Lib.Filter.FilterAggregator"/> class.
        /// </summary>
        /// <param name="fileNamesFilter">File names filter.</param>
        /// <param name="folderNamesFilter">Folder names filter.</param>
        /// <param name="invalidFolderNamesFilter">Invalid folder names filter.</param>
        /// <param name="ignoredFolderFilter">Ignored folder filter.</param>
        public FilterAggregator(
            IgnoredFileNamesFilter fileNamesFilter,
            IgnoredFolderNameFilter folderNamesFilter,
            InvalidFolderNameFilter invalidFolderNamesFilter,
            IgnoredFoldersFilter ignoredFolderFilter,
            SymlinkFilter symlinkFilter = null)
        {
            if (fileNamesFilter == null) {
                throw new ArgumentNullException("fileNamesFilter");
            }

            if (folderNamesFilter == null) {
                throw new ArgumentNullException("folderNamesFilter");
            }

            if (invalidFolderNamesFilter == null) {
                throw new ArgumentNullException("invalidFolderNamesFilter");
            }

            if (ignoredFolderFilter == null) {
                throw new ArgumentNullException("ignoredFolderFilter");
            }

            this.FileNamesFilter = fileNamesFilter;
            this.FolderNamesFilter = folderNamesFilter;
            this.InvalidFolderNamesFilter = invalidFolderNamesFilter;
            this.IgnoredFolderFilter = ignoredFolderFilter;
            this.SymlinkFilter = symlinkFilter ?? new SymlinkFilter();
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CmisSync.Lib.Filter.FilterAggregator"/> class.
        /// </summary>
        /// <param name="fileNamesFilter">File names filter.</param>
        /// <param name="folderNamesFilter">Folder names filter.</param>
        /// <param name="invalidFolderNamesFilter">Invalid folder names filter.</param>
        /// <param name="ignoredFolderFilter">Ignored folder filter.</param>
        public FilterAggregator(
            IgnoredFileNamesFilter fileNamesFilter,
            IgnoredFolderNameFilter folderNamesFilter,
            InvalidFolderNameFilter invalidFolderNamesFilter,
            IgnoredFoldersFilter ignoredFolderFilter,
            SymlinkFilter symlinkFilter = null)
        {
            if (fileNamesFilter == null)
            {
                throw new ArgumentNullException("fileNamesFilter");
            }

            if (folderNamesFilter == null)
            {
                throw new ArgumentNullException("folderNamesFilter");
            }

            if (invalidFolderNamesFilter == null)
            {
                throw new ArgumentNullException("invalidFolderNamesFilter");
            }

            if (ignoredFolderFilter == null)
            {
                throw new ArgumentNullException("ignoredFolderFilter");
            }

            this.FileNamesFilter          = fileNamesFilter;
            this.FolderNamesFilter        = folderNamesFilter;
            this.InvalidFolderNamesFilter = invalidFolderNamesFilter;
            this.IgnoredFolderFilter      = ignoredFolderFilter;
            this.SymlinkFilter            = symlinkFilter ?? new SymlinkFilter();
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReportingFilter"/> class.
        /// </summary>
        /// <param name="queue">Sync Event Queue to put work on.</param>
        /// <param name="ignoredFoldersFilter">Ignored folders filter.</param>
        /// <param name="ignoredFileNameFilter">Ignored file name filter.</param>
        /// <param name="ignoredFolderNameFilter">Ignored folder name filter.</param>
        /// <param name="invalidFoderNameFilter">Invalid folder name filter</param> 
        public ReportingFilter(
            ISyncEventQueue queue,
            IgnoredFoldersFilter ignoredFoldersFilter,
            IgnoredFileNamesFilter ignoredFileNameFilter,
            IgnoredFolderNameFilter ignoredFolderNameFilter,
            InvalidFolderNameFilter invalidFoderNameFilter,
            SymlinkFilter symlinkFilter) : base(queue)
        {
            if (ignoredFoldersFilter == null) {
                throw new ArgumentNullException("ignoredFoldersFilter");
            }

            if (ignoredFileNameFilter == null) {
                throw new ArgumentNullException("ignoredFileNameFilter");
            }

            if (ignoredFolderNameFilter == null) {
                throw new ArgumentNullException("ignoredFolderNameFilter");
            }

            if (invalidFoderNameFilter == null) {
                throw new ArgumentNullException("invalidFoderNameFilter");
            }

            if (symlinkFilter == null) {
                throw new ArgumentNullException("symlinkFilter");
            }

            this.ignoredFoldersFilter = ignoredFoldersFilter;
            this.ignoredFileNameFilter = ignoredFileNameFilter;
            this.ignoredFolderNameFilter = ignoredFolderNameFilter;
            this.invalidFolderNameFilter = invalidFoderNameFilter;
            this.symlinkFilter = symlinkFilter;
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReportingFilter"/> class.
        /// </summary>
        /// <param name="queue">Sync Event Queue to put work on.</param>
        /// <param name="ignoredFoldersFilter">Ignored folders filter.</param>
        /// <param name="ignoredFileNameFilter">Ignored file name filter.</param>
        /// <param name="ignoredFolderNameFilter">Ignored folder name filter.</param>
        /// <param name="invalidFoderNameFilter">Invalid folder name filter</param>
        public ReportingFilter(
            ISyncEventQueue queue,
            IgnoredFoldersFilter ignoredFoldersFilter,
            IgnoredFileNamesFilter ignoredFileNameFilter,
            IgnoredFolderNameFilter ignoredFolderNameFilter,
            InvalidFolderNameFilter invalidFoderNameFilter) : base(queue)
        {
            if (ignoredFoldersFilter == null)
            {
                throw new ArgumentNullException("Given folder filter is null");
            }

            if (ignoredFileNameFilter == null)
            {
                throw new ArgumentNullException("Given file name filter is null");
            }

            if (ignoredFolderNameFilter == null)
            {
                throw new ArgumentNullException("Given folder name filter is null");
            }

            if (invalidFoderNameFilter == null)
            {
                throw new ArgumentNullException("Given invalid folder name filter is null");
            }

            this.ignoredFoldersFilter    = ignoredFoldersFilter;
            this.ignoredFileNameFilter   = ignoredFileNameFilter;
            this.ignoredFolderNameFilter = ignoredFolderNameFilter;
            this.invalidFolderNameFilter = invalidFoderNameFilter;
        }
コード例 #5
0
ファイル: FilterAggregator.cs プロジェクト: sunxk/CmisSync
        /// <summary>
        /// Initializes a new instance of the <see cref="CmisSync.Lib.Filter.FilterAggregator"/> class.
        /// </summary>
        /// <param name="fileNamesFilter">File names filter.</param>
        /// <param name="folderNamesFilter">Folder names filter.</param>
        /// <param name="invalidFolderNamesFilter">Invalid folder names filter.</param>
        /// <param name="ignoredFolderFilter">Ignored folder filter.</param>
        public FilterAggregator(
            IgnoredFileNamesFilter fileNamesFilter,
            IgnoredFolderNameFilter folderNamesFilter,
            InvalidFolderNameFilter invalidFolderNamesFilter,
            IgnoredFoldersFilter ignoredFolderFilter)
        {
            if (fileNamesFilter == null)
            {
                throw new ArgumentNullException("Given file names filter is null");
            }

            if (folderNamesFilter == null)
            {
                throw new ArgumentNullException("Given folder names filter is null");
            }

            if (invalidFolderNamesFilter == null)
            {
                throw new ArgumentNullException("Given invalid folder names filter is null");
            }

            if (ignoredFolderFilter == null)
            {
                throw new ArgumentNullException("Given ignored folder filter is null");
            }

            this.FileNamesFilter          = fileNamesFilter;
            this.FolderNamesFilter        = folderNamesFilter;
            this.InvalidFolderNamesFilter = invalidFolderNamesFilter;
            this.IgnoredFolderFilter      = ignoredFolderFilter;
        }
コード例 #6
0
 public void AllowCorrectEventsTest()
 {
     var filter = new IgnoredFileNamesFilter();
     string reason;
     Assert.That(filter.CheckFile("testfile", out reason), Is.False);
     Assert.That(string.IsNullOrEmpty(reason), Is.True);
 }
コード例 #7
0
 public void DefaultConstrutorAddsRequiredFilter()
 {
     var filter = new IgnoredFileNamesFilter();
     string reason;
     Assert.That(filter.CheckFile("bla.sync", out reason), Is.True);
     Assert.That(reason, Is.Not.Null);
 }
コード例 #8
0
 public void SetUpFilter() {
     this.ignoreFoldersFilter = Mock.Of<IgnoredFoldersFilter>();
     this.ignoreFileNamesFilter = Mock.Of<IgnoredFileNamesFilter>();
     this.ignoreFolderNamesFilter = Mock.Of<IgnoredFolderNameFilter>();
     this.invalidFolderNameFilter = Mock.Of<InvalidFolderNameFilter>();
     this.symlinkFilter = Mock.Of<SymlinkFilter>();
     this.queue = new Mock<ISyncEventQueue>();
 }
コード例 #9
0
 public void HandleIgnoredFileNamesTest()
 {
     List<string> wildcards = new List<string>();
     wildcards.Add("*~");
     var filter = new IgnoredFileNamesFilter { Wildcards = wildcards };
     string reason;
     Assert.That(filter.CheckFile("file~", out reason), Is.True);
     Assert.That(string.IsNullOrEmpty(reason), Is.False);
 }
コード例 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReportingFilter"/> class.
        /// </summary>
        /// <param name="queue">Sync Event Queue to put work on.</param>
        /// <param name="ignoredFoldersFilter">Ignored folders filter.</param>
        /// <param name="ignoredFileNameFilter">Ignored file name filter.</param>
        /// <param name="ignoredFolderNameFilter">Ignored folder name filter.</param>
        /// <param name="invalidFoderNameFilter">Invalid folder name filter</param>
        public ReportingFilter(
            ISyncEventQueue queue,
            IgnoredFoldersFilter ignoredFoldersFilter,
            IgnoredFileNamesFilter ignoredFileNameFilter,
            IgnoredFolderNameFilter ignoredFolderNameFilter,
            InvalidFolderNameFilter invalidFoderNameFilter,
            SymlinkFilter symlinkFilter) : base(queue)
        {
            if (ignoredFoldersFilter == null)
            {
                throw new ArgumentNullException("ignoredFoldersFilter");
            }

            if (ignoredFileNameFilter == null)
            {
                throw new ArgumentNullException("ignoredFileNameFilter");
            }

            if (ignoredFolderNameFilter == null)
            {
                throw new ArgumentNullException("ignoredFolderNameFilter");
            }

            if (invalidFoderNameFilter == null)
            {
                throw new ArgumentNullException("invalidFoderNameFilter");
            }

            if (symlinkFilter == null)
            {
                throw new ArgumentNullException("symlinkFilter");
            }

            this.ignoredFoldersFilter    = ignoredFoldersFilter;
            this.ignoredFileNameFilter   = ignoredFileNameFilter;
            this.ignoredFolderNameFilter = ignoredFolderNameFilter;
            this.invalidFolderNameFilter = invalidFoderNameFilter;
            this.symlinkFilter           = symlinkFilter;
        }
コード例 #11
0
 private void SetUpTestMocks() {
     this.session = new Mock<ISession>();
     this.session.SetupTypeSystem();
     this.storage = new Mock<IMetaDataStorage>();
     this.filters = new Mock<IFilterAggregator>();
     this.fileNameFilter = new IgnoredFileNamesFilter();
     this.folderNameFilter = new IgnoredFolderNameFilter();
     this.filters.Setup(f => f.FileNamesFilter).Returns(this.fileNameFilter);
     this.filters.Setup(f => f.FolderNamesFilter).Returns(this.folderNameFilter);
     this.underTest = new RemoteObjectDeleted(this.session.Object, this.storage.Object, this.filters.Object);
 }
コード例 #12
0
        private SingleStepEventQueue CreateQueue(Mock<ISession> session, IMetaDataStorage storage, ObservableHandler observer, IFileSystemInfoFactory fsFactory = null) {
            var manager = new SyncEventManager();
            SingleStepEventQueue queue = new SingleStepEventQueue(manager);

            manager.AddEventHandler(observer);

            var connectionScheduler = new ConnectionScheduler(new RepoInfo(), queue, Mock.Of<ISessionFactory>(), Mock.Of<IAuthenticationProvider>());
            manager.AddEventHandler(connectionScheduler);

            var changes = new ContentChanges(session.Object, storage, queue, this.maxNumberOfContentChanges, this.isPropertyChangesSupported);
            manager.AddEventHandler(changes);

            var transformer = new ContentChangeEventTransformer(queue, storage, fsFactory);
            manager.AddEventHandler(transformer);

            var ccaccumulator = new ContentChangeEventAccumulator(session.Object, queue);
            manager.AddEventHandler(ccaccumulator);

            var remoteFetcher = new RemoteObjectFetcher(session.Object, storage);
            manager.AddEventHandler(remoteFetcher);

            var localFetcher = new LocalObjectFetcher(storage.Matcher, fsFactory);
            manager.AddEventHandler(localFetcher);

            var watcher = new Strategy.WatcherConsumer(queue);
            manager.AddEventHandler(watcher);

            var localDetection = new LocalSituationDetection();
            var remoteDetection = new RemoteSituationDetection();
            var transmissionManager = new TransmissionManager();
            var activityAggregator = new ActivityListenerAggregator(Mock.Of<IActivityListener>(), transmissionManager);

            var ignoreFolderFilter = new IgnoredFoldersFilter();
            var ignoreFolderNameFilter = new IgnoredFolderNameFilter();
            var ignoreFileNamesFilter = new IgnoredFileNamesFilter();
            var invalidFolderNameFilter = new InvalidFolderNameFilter();
            var filterAggregator = new FilterAggregator(ignoreFileNamesFilter, ignoreFolderNameFilter, invalidFolderNameFilter, ignoreFolderFilter);

            var syncMechanism = new SyncMechanism(localDetection, remoteDetection, queue, session.Object, storage, Mock.Of<IFileTransmissionStorage>(), activityAggregator, filterAggregator);
            manager.AddEventHandler(syncMechanism);

            var remoteFolder = MockSessionUtil.CreateCmisFolder();
            remoteFolder.Setup(r => r.Path).Returns(this.remoteRoot);
            var localFolder = new Mock<IDirectoryInfo>();
            localFolder.Setup(f => f.FullName).Returns(this.localRoot);
            var generator = new CrawlEventGenerator(storage, fsFactory);
            var ignoreStorage = new IgnoredEntitiesStorage(new IgnoredEntitiesCollection(), storage);
            var treeBuilder = new DescendantsTreeBuilder(storage, remoteFolder.Object, localFolder.Object, filterAggregator, ignoreStorage);
            var notifier = new CrawlEventNotifier(queue);
            var crawler = new DescendantsCrawler(queue, treeBuilder, generator, notifier, Mock.Of<IActivityListener>());
            manager.AddEventHandler(crawler);

            var permissionDenied = new GenericHandleDublicatedEventsFilter<PermissionDeniedEvent, ConfigChangedEvent>();
            manager.AddEventHandler(permissionDenied);

            var alreadyAddedFilter = new IgnoreAlreadyHandledFsEventsFilter(storage, fsFactory);
            manager.AddEventHandler(alreadyAddedFilter);

            var ignoreContentChangesFilter = new IgnoreAlreadyHandledContentChangeEventsFilter(storage, session.Object);
            manager.AddEventHandler(ignoreContentChangesFilter);

            var delayRetryAndNextSyncEventHandler = new DelayRetryAndNextSyncEventHandler(queue);
            manager.AddEventHandler(delayRetryAndNextSyncEventHandler);

            /* This is not implemented yet
            var failedOperationsFilder = new FailedOperationsFilter(queue);
            manager.AddEventHandler(failedOperationsFilder);
            */

            var reportingFilter = new ReportingFilter(queue, ignoreFolderFilter, ignoreFileNamesFilter, ignoreFolderNameFilter, invalidFolderNameFilter, new SymlinkFilter());
            manager.AddEventHandler(reportingFilter);

            var debugHandler = new DebugLoggingHandler();
            manager.AddEventHandler(debugHandler);

            var movedOrRenamed = new RemoteObjectMovedOrRenamedAccumulator(queue, storage, fsFactory);
            manager.AddEventHandler(movedOrRenamed);

            return queue;
        }
コード例 #13
0
 public void CreateFilter() {
     arg0 = new IgnoredFileNamesFilter();
     arg1 = new IgnoredFolderNameFilter();
     arg2 = new InvalidFolderNameFilter();
     arg3 = new IgnoredFoldersFilter();
 }