/// <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;
        }
示例#2
0
 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>();
 }
        /// <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;
        }
        /// <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);
        }
示例#5
0
        /// <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.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;
        }
示例#7
0
        /// <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;
        }
示例#8
0
        /// <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;
        }
示例#9
0
        /// <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;
        }
示例#10
0
        /// <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;
        }
示例#11
0
        /// <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='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,
            RepoInfo repoInfo,
            IFilterAggregator filter,
            ActivityListenerAggregator activityListener,
            IFileSystemInfoFactory fsFactory = null) : base(queue)
        {
            if (storage == null)
            {
                throw new ArgumentNullException("storage null");
            }

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

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

            if (activityListener == null)
            {
                throw new ArgumentNullException("Given activityListener is null");
            }

            if (fsFactory == null)
            {
                this.fileSystemFactory = new FileSystemInfoFactory();
            }
            else
            {
                this.fileSystemFactory = fsFactory;
            }

            this.filter           = filter;
            this.repoInfo         = repoInfo;
            this.storage          = storage;
            this.activityListener = activityListener;
        }
示例#12
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);
        }
示例#13
0
        /// <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;
        }
        /// <summary>
        /// Gets the remote directory tree.
        /// </summary>
        /// <returns>The remote directory tree.</returns>
        /// <param name="parent">Parent folder.</param>
        /// <param name="descendants">Descendants of remote object.</param>
        /// <param name="filter">Filter of ignored or invalid files and folder</param>
        public static IObjectTree<IFileableCmisObject> GetRemoteDirectoryTree(IFolder parent, IList<ITree<IFileableCmisObject>> descendants, IFilterAggregator filter, IIgnoredEntitiesStorage ignoredStorage, IPathMatcher matcher) {
            IList<IObjectTree<IFileableCmisObject>> children = new List<IObjectTree<IFileableCmisObject>>();
            if (descendants != null) {
                foreach (var child in descendants) {
                    if (child.Item is IFolder) {
                        string reason;
                        var folder = child.Item as IFolder;
                        if (!filter.FolderNamesFilter.CheckFolderName(folder.Name, out reason) && !filter.InvalidFolderNamesFilter.CheckFolderName(folder.Name, out reason)) {
                            if (folder.AreAllChildrenIgnored()) {
                                ignoredStorage.AddOrUpdateEntryAndDeleteAllChildrenFromStorage(new IgnoredEntity(folder, matcher));
                                Logger.Info(string.Format("Folder {0} with Id {1} is ignored", folder.Name, folder.Id));
                                children.Add(new ObjectTree<IFileableCmisObject> {
                                    Item = child.Item,
                                    Children = new List<IObjectTree<IFileableCmisObject>>()
                                });
                            } else {
                                ignoredStorage.Remove(folder.Id);
                                children.Add(GetRemoteDirectoryTree(folder, child.Children, filter, ignoredStorage, matcher));
                            }
                        } else {
                            Logger.Info(reason);
                        }
                    } else if (child.Item is IDocument) {
                        string reason;
                        if (!filter.FileNamesFilter.CheckFile(child.Item.Name, out reason)) {
                            children.Add(new ObjectTree<IFileableCmisObject> {
                                Item = child.Item,
                                Children = new List<IObjectTree<IFileableCmisObject>>()
                            });
                        } else {
                            Logger.Info(reason);
                        }
                    }
                }
            }

            var tree = new ObjectTree<IFileableCmisObject> {
                Item = parent,
                Children = children
            };

            return tree;
        }
 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, true);
     this.storage.SaveMappedObject(this.mappedRootObject);
     this.filter = MockOfIFilterAggregatorUtil.CreateFilterAggregator().Object;
     this.listener = new Mock<IActivityListener>();
 }
示例#16
0
        /// <summary>
        /// Gets the local directory tree.
        /// </summary>
        /// <returns>The local directory tree.</returns>
        /// <param name="parent">Parent directory.</param>
        /// <param name="filter">Filter for files.</param>
        public static IObjectTree <IFileSystemInfo> GetLocalDirectoryTree(IDirectoryInfo parent, IFilterAggregator filter)
        {
            var children = new List <IObjectTree <IFileSystemInfo> >();

            try {
                foreach (var child in parent.GetDirectories())
                {
                    string reason;
                    if (!filter.InvalidFolderNamesFilter.CheckFolderName(child.Name, out reason) && !filter.FolderNamesFilter.CheckFolderName(child.Name, out reason) && !filter.SymlinkFilter.IsSymlink(child, out reason))
                    {
                        children.Add(GetLocalDirectoryTree(child, filter));
                    }
                    else
                    {
                        Logger.Info(reason);
                    }
                }

                foreach (var file in parent.GetFiles())
                {
                    string reason;
                    if (!filter.FileNamesFilter.CheckFile(file.Name, out reason) && !filter.SymlinkFilter.IsSymlink(file, out reason))
                    {
                        children.Add(new ObjectTree <IFileSystemInfo> {
                            Item     = file,
                            Children = new List <IObjectTree <IFileSystemInfo> >()
                        });
                    }
                    else
                    {
                        Logger.Info(reason);
                    }
                }
            } catch (System.IO.PathTooLongException) {
                Logger.Fatal(string.Format("One or more children paths of \"{0}\" are to long to be synchronized, synchronization is impossible since the problem is fixed", parent.FullName));
                throw;
            }

            IObjectTree <IFileSystemInfo> tree = new ObjectTree <IFileSystemInfo> {
                Item     = parent,
                Children = children
            };

            return(tree);
        }
示例#17
0
        /// <summary>
        /// Gets the remote directory tree.
        /// </summary>
        /// <returns>The remote directory tree.</returns>
        /// <param name="parent">Parent folder.</param>
        /// <param name="descendants">Descendants of remote object.</param>
        /// <param name="filter">Filter of ignored or invalid files and folder</param>
        public static IObjectTree <IFileableCmisObject> GetRemoteDirectoryTree(IFolder parent, IList <ITree <IFileableCmisObject> > descendants, IFilterAggregator filter, IIgnoredEntitiesStorage ignoredStorage, IPathMatcher matcher)
        {
            IList <IObjectTree <IFileableCmisObject> > children = new List <IObjectTree <IFileableCmisObject> >();

            if (descendants != null)
            {
                foreach (var child in descendants)
                {
                    if (child.Item is IFolder)
                    {
                        string reason;
                        var    folder = child.Item as IFolder;
                        if (!filter.FolderNamesFilter.CheckFolderName(folder.Name, out reason) && !filter.InvalidFolderNamesFilter.CheckFolderName(folder.Name, out reason))
                        {
                            if (folder.AreAllChildrenIgnored())
                            {
                                ignoredStorage.AddOrUpdateEntryAndDeleteAllChildrenFromStorage(new IgnoredEntity(folder, matcher));
                                Logger.Info(string.Format("Folder {0} with Id {1} is ignored", folder.Name, folder.Id));
                                children.Add(new ObjectTree <IFileableCmisObject> {
                                    Item     = child.Item,
                                    Children = new List <IObjectTree <IFileableCmisObject> >()
                                });
                            }
                            else
                            {
                                ignoredStorage.Remove(folder.Id);
                                children.Add(GetRemoteDirectoryTree(folder, child.Children, filter, ignoredStorage, matcher));
                            }
                        }
                        else
                        {
                            Logger.Info(reason);
                        }
                    }
                    else if (child.Item is IDocument)
                    {
                        string reason;
                        if (!filter.FileNamesFilter.CheckFile(child.Item.Name, out reason))
                        {
                            children.Add(new ObjectTree <IFileableCmisObject> {
                                Item     = child.Item,
                                Children = new List <IObjectTree <IFileableCmisObject> >()
                            });
                        }
                        else
                        {
                            Logger.Info(reason);
                        }
                    }
                }
            }

            var tree = new ObjectTree <IFileableCmisObject> {
                Item     = parent,
                Children = children
            };

            return(tree);
        }
示例#18
0
        /// <summary>
        /// Gets the remote directory tree.
        /// </summary>
        /// <returns>The remote directory tree.</returns>
        /// <param name="parent">Parent folder.</param>
        /// <param name="descendants">Descendants of remote object.</param>
        /// <param name="filter">Filter of ignored or invalid files and folder</param>
        public static IObjectTree <IFileableCmisObject> GetRemoteDirectoryTree(IFolder parent, IList <ITree <IFileableCmisObject> > descendants, IFilterAggregator filter)
        {
            IList <IObjectTree <IFileableCmisObject> > children = new List <IObjectTree <IFileableCmisObject> >();

            if (descendants != null)
            {
                foreach (var child in descendants)
                {
                    if (child.Item is IFolder)
                    {
                        string reason;
                        if (!filter.FolderNamesFilter.CheckFolderName(child.Item.Name, out reason) && !filter.InvalidFolderNamesFilter.CheckFolderName(child.Item.Name, out reason))
                        {
                            children.Add(GetRemoteDirectoryTree(child.Item as IFolder, child.Children, filter));
                        }
                        else
                        {
                            Logger.Info(reason);
                        }
                    }
                    else if (child.Item is IDocument)
                    {
                        string reason;
                        if (!filter.FileNamesFilter.CheckFile(child.Item.Name, out reason))
                        {
                            children.Add(new ObjectTree <IFileableCmisObject> {
                                Item     = child.Item,
                                Children = new List <IObjectTree <IFileableCmisObject> >()
                            });
                        }
                        else
                        {
                            Logger.Info(reason);
                        }
                    }
                }
            }

            var tree = new ObjectTree <IFileableCmisObject> {
                Item     = parent,
                Children = children
            };

            return(tree);
        }
示例#19
0
        /// <summary>
        /// Gets the local directory tree.
        /// </summary>
        /// <returns>The local directory tree.</returns>
        /// <param name="parent">Parent directory.</param>
        /// <param name="filter">Filter for files.</param>
        public static IObjectTree <IFileSystemInfo> GetLocalDirectoryTree(IDirectoryInfo parent, IFilterAggregator filter)
        {
            var children = new List <IObjectTree <IFileSystemInfo> >();

            foreach (var child in parent.GetDirectories())
            {
                string reason;
                if (!filter.InvalidFolderNamesFilter.CheckFolderName(child.Name, out reason) && !filter.FolderNamesFilter.CheckFolderName(child.Name, out reason))
                {
                    children.Add(GetLocalDirectoryTree(child, filter));
                }
                else
                {
                    Logger.Info(reason);
                }
            }

            foreach (var file in parent.GetFiles())
            {
                string reason;
                if (!filter.FileNamesFilter.CheckFile(file.Name, out reason))
                {
                    children.Add(new ObjectTree <IFileSystemInfo> {
                        Item     = file,
                        Children = new List <IObjectTree <IFileSystemInfo> >()
                    });
                }
                else
                {
                    Logger.Info(reason);
                }
            }

            IObjectTree <IFileSystemInfo> tree = new ObjectTree <IFileSystemInfo> {
                Item     = parent,
                Children = children
            };

            return(tree);
        }
        /// <summary>
        /// Gets the local directory tree.
        /// </summary>
        /// <returns>The local directory tree.</returns>
        /// <param name="parent">Parent directory.</param>
        /// <param name="filter">Filter for files.</param>
        public static IObjectTree<IFileSystemInfo> GetLocalDirectoryTree(IDirectoryInfo parent, IFilterAggregator filter) {
            var children = new List<IObjectTree<IFileSystemInfo>>();
            try {
                foreach (var child in parent.GetDirectories()) {
                    string reason;
                    if (!filter.InvalidFolderNamesFilter.CheckFolderName(child.Name, out reason) && !filter.FolderNamesFilter.CheckFolderName(child.Name, out reason) && !filter.SymlinkFilter.IsSymlink(child, out reason)) {
                        children.Add(GetLocalDirectoryTree(child, filter));
                    } else {
                        Logger.Info(reason);
                    }
                }

                foreach (var file in parent.GetFiles()) {
                    string reason;
                    if (!filter.FileNamesFilter.CheckFile(file.Name, out reason) && !filter.SymlinkFilter.IsSymlink(file, out reason)) {
                        children.Add(new ObjectTree<IFileSystemInfo> {
                            Item = file,
                            Children = new List<IObjectTree<IFileSystemInfo>>()
                        });
                    } else {
                        Logger.Info(reason);
                    }
                }
            } catch (System.IO.PathTooLongException) {
                Logger.Fatal(string.Format("One or more children paths of \"{0}\" are to long to be synchronized, synchronization is impossible since the problem is fixed", parent.FullName));
                throw;
            }

            IObjectTree<IFileSystemInfo> tree = new ObjectTree<IFileSystemInfo> {
                Item = parent,
                Children = children
            };
            return tree;
        }