Stores the metadata for a node representing a folder on a file system.
        /// <summary>
        /// Returns a folder object for the specified node.
        /// </summary>
        public ArchiveFolderState GetFolderState(ISystemContext context, string rootId)
        {
            StringBuilder path = new StringBuilder();
            path.Append(m_configuration.ArchiveRoot);
            path.Append('/');
            path.Append(rootId);

            ArchiveFolder folder = new ArchiveFolder(rootId, new DirectoryInfo(path.ToString()));
            return new ArchiveFolderState(context, folder, m_namespaceIndex);
        }
Exemple #2
0
        /// <summary>
        /// Returns a folder object for the specified node.
        /// </summary>
        public ArchiveFolderState GetFolderState(ISystemContext context, string rootId)
        {
            StringBuilder path = new StringBuilder();

            path.Append(m_configuration.ArchiveRoot);
            path.Append('/');
            path.Append(rootId);

            ArchiveFolder folder = new ArchiveFolder(rootId, new DirectoryInfo(path.ToString()));

            return(new ArchiveFolderState(context, folder, m_namespaceIndex));
        }
        /// <summary>
        /// Creates a new instance of a folder.
        /// </summary>
        public ArchiveFolderState(ISystemContext context, ArchiveFolder folder, ushort namespaceIndex)
            :
            base(null)
        {
            m_archiveFolder = folder;

            this.TypeDefinitionId = ObjectTypeIds.FolderType;
            this.SymbolicName     = folder.Name;
            this.NodeId           = ConstructId(folder.UniquePath, namespaceIndex);
            this.BrowseName       = new QualifiedName(folder.Name, namespaceIndex);
            this.DisplayName      = new LocalizedText(this.BrowseName.Name);
            this.Description      = null;
            this.WriteMask        = 0;
            this.UserWriteMask    = 0;
            this.EventNotifier    = EventNotifiers.None;
        }
        /// <summary>
        /// Creates a new instance of a folder.
        /// </summary>
        public ArchiveFolderState(ISystemContext context, ArchiveFolder folder, ushort namespaceIndex)
        : 
            base(null)
        {
            m_archiveFolder = folder;

            this.TypeDefinitionId = ObjectTypeIds.FolderType;
            this.SymbolicName = folder.Name;
            this.NodeId = ConstructId(folder.UniquePath, namespaceIndex);
            this.BrowseName = new QualifiedName(folder.Name, namespaceIndex);
            this.DisplayName = new LocalizedText(this.BrowseName.Name);
            this.Description = null;
            this.WriteMask = 0;
            this.UserWriteMask = 0;
            this.EventNotifier = EventNotifiers.None;
        }
        /// <summary>
        /// Returns the next child.
        /// </summary>
        private IReference NextChild()
        {
            UnderlyingSystem system = (UnderlyingSystem)this.SystemContext.SystemHandle;

            NodeId targetId = null;

            // check if a specific browse name is requested.
            if (!QualifiedName.IsNull(base.BrowseName))
            {
                // check if match found previously.
                if (m_position == Int32.MaxValue)
                {
                    return(null);
                }

                // browse name must be qualified by the correct namespace.
                if (m_source.BrowseName.NamespaceIndex != base.BrowseName.NamespaceIndex)
                {
                    return(null);
                }

                // look for matching folder.
                if (m_stage == Stage.Folders && m_folders != null)
                {
                    for (int ii = 0; ii < m_folders.Length; ii++)
                    {
                        if (base.BrowseName.Name == m_folders[ii].Name)
                        {
                            targetId = ArchiveFolderState.ConstructId(m_folders[ii].UniquePath, m_source.NodeId.NamespaceIndex);
                            break;
                        }
                    }
                }

                // look for matching item.
                else if (m_stage == Stage.Items && m_items != null)
                {
                    for (int ii = 0; ii < m_items.Length; ii++)
                    {
                        if (base.BrowseName.Name == m_items[ii].Name)
                        {
                            targetId = ArchiveItemState.ConstructId(m_items[ii].UniquePath, m_source.NodeId.NamespaceIndex);
                            break;
                        }
                    }
                }

                // look for matching parent.
                else if (m_stage == Stage.Parents)
                {
                    ArchiveFolder parent = m_source.ArchiveFolder.GetParentFolder();

                    if (base.BrowseName.Name == parent.Name)
                    {
                        targetId = ArchiveFolderState.ConstructId(parent.UniquePath, m_source.NodeId.NamespaceIndex);
                    }
                }

                m_position = Int32.MaxValue;
            }

            // return the child at the next position.
            else
            {
                // look for next folder.
                if (m_stage == Stage.Folders && m_folders != null)
                {
                    if (m_position >= m_folders.Length)
                    {
                        return(null);
                    }

                    targetId = ArchiveFolderState.ConstructId(m_folders[m_position++].UniquePath, m_source.NodeId.NamespaceIndex);
                }

                // look for next item.
                else if (m_stage == Stage.Items && m_items != null)
                {
                    if (m_position >= m_items.Length)
                    {
                        return(null);
                    }

                    targetId = ArchiveItemState.ConstructId(m_items[m_position++].UniquePath, m_source.NodeId.NamespaceIndex);
                }

                // look for matching parent.
                else if (m_stage == Stage.Parents)
                {
                    ArchiveFolder parent = m_source.ArchiveFolder.GetParentFolder();

                    if (parent != null)
                    {
                        targetId = ArchiveFolderState.ConstructId(parent.UniquePath, m_source.NodeId.NamespaceIndex);
                    }
                }
            }

            // create reference.
            if (targetId != null)
            {
                return(new NodeStateReference(ReferenceTypeIds.Organizes, false, targetId));
            }

            return(null);
        }