コード例 #1
0
ファイル: iFolderEntry.cs プロジェクト: lulzzz/simias
        /// <summary>
        /// Create An iFolder Entry
        /// </summary>
        /// <param name="c"></param>
        /// <param name="parent"></param>
        /// <param name="type"></param>
        /// <param name="entryName"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        internal static Node CreateEntry(Collection c, Node parent,
                                         iFolderEntryType type, string entryName, out string path)
        {
            bool DontCheckPolicies = false;

            return(CreateEntry(c, parent, type, entryName, out path, DontCheckPolicies));
        }
コード例 #2
0
ファイル: iFolderEntry.cs プロジェクト: lulzzz/simias
        /// <summary>
        /// Create An iFolder Entry
        /// </summary>
        /// <param name="ifolderID">The iFolder ID</param>
        /// <param name="parentID">The Parent Entry ID</param>
        /// <param name="entryName">The New Entry Name</param>
        /// <param name="type">The iFolder Entry Type</param>
        /// <param name="accessID">The Access User ID</param>
        /// <returns>An iFolderEntry Object</returns>
        public static iFolderEntry CreateEntry(string ifolderID, string parentID,
                                               iFolderEntryType type, string entryName, string accessID)
        {
            bool dontCheckForPolicy = false;

            return(CreateEntry(ifolderID, parentID, type, entryName, accessID, dontCheckForPolicy));
        }
コード例 #3
0
ファイル: iFolderEntry.cs プロジェクト: lulzzz/simias
        /// <summary>
        /// Create An iFolder Entry
        /// </summary>
        /// <param name="c"></param>
        /// <param name="parent"></param>
        /// <param name="type"></param>
        /// <param name="entryName"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        internal static Node CreateEntry(Collection c, Node parent,
                                         iFolderEntryType type, string entryName, out string path, bool DontCheckPolicies)
        {
            Node result = null;

            // NOTE: a new entry off the iFolder is not allowed, it must be off the root directory node or lower
            if ((parent == null) || (c.ID.Equals(parent.ID)))
            {
                throw new EntryDoesNotExistException(parent.ID);
            }

            // NOTE: only directories can have children
            if (!parent.IsBaseType(NodeTypes.DirNodeType))
            {
                throw new DirectoryEntryRequiredException(parent.ID);
            }

            // check the name
            CheckName(entryName);

            // create new path
            DirNode parentDirNode = (DirNode)parent;

            path = parentDirNode.GetFullPath(c);
            path = System.IO.Path.Combine(path, entryName);

            // check for existing entry (case insensitive test)
            if (SyncFile.DoesNodeExist(c, parentDirNode, entryName))
            {
                throw new EntryAlreadyExistException(entryName);
            }

            // directory
            if (type == iFolderEntryType.Directory)
            {
                result = new DirNode(c, parentDirNode, entryName);
            }
            // file
            else
            {
                if (DontCheckPolicies == false)
                {
                    // check file type policy
                    FileTypeFilter filter = FileTypeFilter.Get(c);
                    if (!filter.Allowed(entryName))
                    {
                        throw new FileTypeException(entryName);
                    }
                }

                result = new FileNode(c, parentDirNode, entryName);
            }

            return(result);
        }
コード例 #4
0
        public virtual iFolderEntry CreateEntry(string ifolderID, string parentID, iFolderEntryType type, string entryName)
        {
            iFolderEntry result = null;

            try
            {
                result = iFolderEntry.CreateEntry(ifolderID, parentID, type, entryName, GetAccessID());
            }
            catch (Exception e)
            {
                SmartException.Throw(e);
            }

            return(result);
        }
コード例 #5
0
ファイル: iFolderEntry.cs プロジェクト: lulzzz/simias
        /// <summary>
        /// Create An iFolder Entry
        /// </summary>
        /// <param name="ifolderID">The iFolder ID</param>
        /// <param name="parentID">The Parent Entry ID</param>
        /// <param name="entryName">The New Entry Name</param>
        /// <param name="type">The iFolder Entry Type</param>
        /// <param name="accessID">The Access User ID</param>
        /// <returns>An iFolderEntry Object</returns>
        public static iFolderEntry CreateEntry(string ifolderID, string parentID,
                                               iFolderEntryType type, string entryName, string accessID, bool DontCheckPolicies)
        {
            Store store = Store.GetStore();

            // collection
            Collection c = store.GetCollectionByID(ifolderID);

            if (c == null)
            {
                throw new iFolderDoesNotExistException(ifolderID);
            }

            // does member exist?
            Member member = c.GetMemberByID(accessID);

            if (member == null && Simias.Service.Manager.LdapServiceEnabled == true)
            {
                Domain   domain = store.GetDomain(store.DefaultDomain);
                string[] IDs    = domain.GetMemberFamilyList(accessID);
                foreach (string id in IDs)
                {
                    member = c.GetMemberByID(id);
                    if (member != null)
                    {
                        break;
                    }
                }
            }

            if (member == null)
            {
                throw new MemberDoesNotExistException(accessID);
            }

            // impersonate
            iFolder.Impersonate(c, accessID);

            Node parent = c.GetNodeByID(parentID);

            string path;
            Node   entry = CreateEntry(c, parent, type, entryName, out path, DontCheckPolicies);

            // directory
            if (type == iFolderEntryType.Directory)
            {
                try
                {
                    // create directory and node
                    DirectoryInfo info = Directory.CreateDirectory(path);

                    // update
                    (entry as DirNode).CreationTime = info.CreationTime;

                    c.Commit(entry);
                }
                catch
                {
                    if (Directory.Exists(path))
                    {
                        Directory.Delete(path);
                    }

                    throw;
                }
            }

            // file
            else
            {
                if (DontCheckPolicies == false)
                {
                    // check file type policy
                    FileTypeFilter filter = FileTypeFilter.Get(c);
                    if (!filter.Allowed(entryName))
                    {
                        throw new FileTypeException(entryName);
                    }
                }

                try
                {
                    // create the file and node
                    File.Create(path).Close();

                    // update
                    (entry as FileNode).UpdateFileInfo(c);

                    c.Commit(entry);
                }
                catch
                {
                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }

                    throw;
                }
            }

            // open the new node
            Node n = c.GetNodeByID(entry.ID);

            return(iFolderEntry.GetEntry(c, n));
        }
コード例 #6
0
 public override iFolderEntry CreateEntry(string ifolderID, string parentID, iFolderEntryType type, string entryName)
 {
     return(base.CreateEntry(ifolderID, parentID, type, entryName));
 }