Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CmisSync.Lib.Producer.Crawler.DescendantsCrawler"/> class based on its internal classes.
        /// This is mostly usefull for Unit Testing
        /// </summary>
        /// <param name='queue'>
        /// The event queue.
        /// </param>
        /// <param name='builder'>
        /// The DescendantsTreeBuilder.
        /// </param>
        /// <param name='generator'>
        /// The CrawlEventGenerator.
        /// </param>
        /// <param name="notifier">
        /// Event Notifier.
        /// </param>
        /// <param name='activityListener'>
        /// Activity listener.
        /// </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 DescendantsCrawler(
            ISyncEventQueue queue,
            IDescendantsTreeBuilder builder,
            CrawlEventGenerator generator,
            CrawlEventNotifier notifier,
            IActivityListener activityListener)
            : base(queue)
        {
            if (activityListener == null)
            {
                throw new ArgumentNullException("activityListener");
            }

            this.activityListener = activityListener;
            this.treebuilder      = builder;
            this.eventGenerator   = generator;
            this.notifier         = notifier;
        }
Exemple #2
0
        /// <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);
        }
        /// <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);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CmisSync.Lib.Producer.Crawler.DescendantsCrawler"/> class based on its internal classes.
        /// This is mostly usefull for Unit Testing
        /// </summary>
        /// <param name='queue'>
        /// The event queue.
        /// </param>
        /// <param name='builder'>
        /// The DescendantsTreeBuilder.
        /// </param>
        /// <param name='generator'>
        /// The CrawlEventGenerator.
        /// </param>
        /// <param name="notifier">
        /// Event Notifier.
        /// </param>
        /// <param name='activityListener'>
        /// Activity listener.
        /// </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 DescendantsCrawler(
            ISyncEventQueue queue,
            IDescendantsTreeBuilder builder,
            CrawlEventGenerator generator,
            CrawlEventNotifier notifier,
            IActivityListener activityListener)
            : base(queue)
        {
            if (activityListener == null) {
                throw new ArgumentNullException("activityListener");
            }

            this.activityListener = activityListener;
            this.treebuilder = builder;
            this.eventGenerator = generator;
            this.notifier = notifier;
        }
        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;
        }
 private DescendantsCrawler CreateCrawler() {
     var generator = new CrawlEventGenerator(this.storage, this.fsFactory.Object);
     var treeBuilder = new DescendantsTreeBuilder(this.storage, this.remoteFolder.Object, this.localFolder.Object, this.filter, Mock.Of<IIgnoredEntitiesStorage>());
     var notifier = new CrawlEventNotifier(this.queue.Object);
     return new DescendantsCrawler(this.queue.Object, treeBuilder, generator, notifier, this.listener.Object);
 }
 public void SetUp() {
     this.storage = new Mock<IMetaDataStorage>();
     this.fsFactory = new Mock<IFileSystemInfoFactory>();
     this.underTest = new CrawlEventGenerator(this.storage.Object, this.fsFactory.Object);
 }