예제 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parentContainer"></param>
        /// <param name="newContainerName"></param>
        /// <returns></returns>
        public Container CreateContainer(Containable parentContainer, String newContainerName)
        {
            if (newContainerName == null) throw new ArgumentNullException("newContainerName");
            if (String.IsNullOrWhiteSpace(newContainerName)) throw new ArgumentNullException("containerName");

            if (Regex.IsMatch(newContainerName, "[*?|:<>\"/\\\\]|[\\p{C}-[ ]]"))
                throw new ArgumentException("コンテナ名には * ? | \" < > : / \\ および制御文字を含めることはできません");
            if (Regex.IsMatch(newContainerName, "^[_.]"))
                throw new ArgumentException("コンテナ名をドットまたは_ではじめることはできません。");

            var newContainerPath = Path.Combine(parentContainer.PhysicalPath, newContainerName);
            if (Directory.Exists(newContainerPath) || Directory.Exists(newContainerPath))
                throw new ArgumentException("指定された名前のページまたはコンテナはすでに存在しています");

            if (parentContainer.CanWrite)
            {
                Directory.CreateDirectory(newContainerPath);
                return GetContainer(parentContainer.Path + "/" + newContainerName, null);
            }

            throw new UnauthorizedAccessException();
        }
예제 #2
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var siteRootDir = ConfigurationManager.AppSettings["Iroha.WebPages.SiteRootDirectory"];
            if (siteRootDir.StartsWith("~/"))
                siteRootDir = Server.MapPath(siteRootDir);
            var versionsDir = ConfigurationManager.AppSettings["Iroha.WebPages.VersionsDirectory"];
            if (versionsDir.StartsWith("~/"))
                versionsDir = Server.MapPath(versionsDir);

            _contentManager = new ContentManager(siteRootDir, versionsDir,new WindowsPrincipal(User.Identity as WindowsIdentity));

            _rootContainer = _contentManager.GetContainer("", null);
            _targetContainable = _contentManager.GetContainable(filterContext.RouteData.Values.ContainsKey("pagePath") ? filterContext.RouteData.Values["pagePath"].ToString() : "");

            base.OnActionExecuting(filterContext);
        }
예제 #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="containable"></param>
        /// <returns></returns>
        public void Delete(Containable containable)
        {
            if (containable is Container)
            {
                // TODO: ContentPageと同様に子供ページをバージョンに追加する
                Directory.Delete(containable.PhysicalPath, true);
            }
            else
            {
                // current -> version
                var currentContentPage = GetContentPage(containable.Path, containable.Parent);
                CreateNewContentPageVersion(currentContentPage);

                File.Delete(containable.PhysicalPath);
            }
        }