コード例 #1
0
        internal List <WikiFileInfo> _WikiFileCreateFilesList(string dir, WikiFileType type)
        {
            List <WikiFileInfo> flst = new List <WikiFileInfo>();

            foreach (string f in Directory.GetFiles(dir))
            {
                FileInfo     fi = new FileInfo(f);
                WikiFileInfo wl = new WikiFileInfo();
                wl.TimeWrite  = fi.LastWriteTime;
                wl.TimeAccess = fi.LastAccessTime;
                wl.TimeAdd    = DateTime.Now;
                wl.FilePath   = f;
                wl.FileLock   = DateTime.MinValue;
                wl.FileType   = type;

                if (wl.FileType == WikiFileType.FileReadMd)
                {
                    wl.FileName = Path.GetFileNameWithoutExtension(f);
                    wl.FileExt  = DokuUtil.WikiFileExtToString(f);
                }
                else
                {
                    wl.FileName = Path.GetFileName(f);
                    wl.FileExt  = DokuUtil.WikiFileExtToString(f);
                }
                flst.Add(wl);
            }
            return(flst);
        }
コード例 #2
0
 private string __getFileExt(WikiFileType wft)
 {
     return((wft == WikiFileType.FileWriteMd) ?
            WikiFile.mdExtension :
            WikiFile.binExtension
            );
 }
コード例 #3
0
 internal string _WikiFileCacheId(WikiFileType wft, string src)
 {
     return
         (DokuUtil.WikiFileTypeToString(wft) + cacheReplace1 +
          src
          .Replace(":", cacheReplace1)
          .Replace(WikiFile.wikiDefaultSeparator, cacheReplace2));
 }
コード例 #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="wft"></param>
 /// <param name="strong"></param>
 /// <param name="namesspace"></param>
 /// <param name="search"></param>
 /// <param name="atticid"></param>
 /// <param name="iswrite"></param>
 public WikiFileParse(WikiFileType wft, bool strong, string namesspace = null, string search = null, string atticid = null, bool iswrite = false)
 {
     FolderType       = wft;
     UriPart          = new List <string>();
     CacheId          = String.Empty;
     AtticId          = ((string.IsNullOrWhiteSpace(atticid)) ? String.Empty : atticid);
     SearchPatern     = ((string.IsNullOrWhiteSpace(search)) ? String.Empty : search);
     NameSpacePatern  = ((string.IsNullOrWhiteSpace(namesspace)) ? ":" : namesspace);
     IsStrongSearch   = strong;
     FolderInfo       = default(WikiFolderInfo);
     IsWriteOperation = iswrite;
 }
コード例 #5
0
 /// <summary>
 /// get page list default ?
 /// </summary>
 private static byte[] _WikiGetList(WikiFile wiki, WikiFileType type, string namesspace)
 {
     /*
      * Dictionary<string, List<WikiFileInfo>> dwf = null;
      * bool isNameSpace = namesspace.Contains(":");
      * switch (type)
      * {
      *  default:
      *  case WikiFileType.FileReadMd:
      *  case WikiFileType.FileWriteMd:
      *      {
      *          dwf = ((isNameSpace) ?
      *              wiki.GetFileListPages(namesspace) :
      *              wiki.GetFileListPages()
      *          );
      *          break;
      *      }
      *  case WikiFileType.FileReadBinary:
      *  case WikiFileType.FileWriteBinary:
      *      {
      *          dwf = ((isNameSpace) ?
      *              wiki.GetFileListMedia(namesspace) :
      *              wiki.GetFileListMedia()
      *          );
      *          break;
      *      }
      *  case WikiFileType.FileReadAttic:
      *  case WikiFileType.FileWriteAttic:
      *      {
      *          dwf = ((isNameSpace) ?
      *              wiki.GetFileListAttic(namesspace) :
      *              wiki.GetFileListAttic()
      *          );
      *          break;
      *      }
      *  case WikiFileType.FileWriteMeta:
      *  case WikiFileType.FileReadMeta:
      *      {
      *          throw new WikiNotImplementPageException(type.ToString());
      *      }
      * }
      * if (dwf == null)
      * {
      *  return null;
      * }
      * return Encoding.UTF8.GetBytes(
      *  wiki.PageListToMdString(dwf, null)
      * );
      */
     return(null);
 }
コード例 #6
0
        /// <summary>
        /// Get file information from FS from string
        /// </summary>
        /// <param name="wft">type enum <see cref="WikiEngine.WikiFileType"/>WikiEngine.WikiFileType</param>
        /// <param name="namesspace">wiki namespace include ':'</param>
        /// <param name="file">page/media name (serch patern string)</param>
        /// <returns><see cref="WikiEngine.WikiFileInfo"/>WikiEngine.WikiFileInfo</returns>
        internal WikiFileInfo _WikiFileGetFileInfo(WikiFileType wft, string namesspace, string file)
        {
            try
            {
                WikiFileParse wfp = new WikiFileParse(wft, true, namesspace, file);

                if ((wfp = this.__WikiFilesParse(wfp)) == null)
                {
                    throw new WikiEngineInternalSearchErrorException(namesspace + file);
                }
                return(this.__WikiFileGetFileInfoSelect(wfp));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #7
0
        /// <summary>
        /// internal Uri/Namespace parse
        /// </summary>
        /// <param name="wft">type enum <see cref="WikiEngine.WikiFileType"/>WikiEngine.WikiFileType</param>
        /// <param name="namesspace">wiki namespace include ':'</param>
        /// <param name="file">page/media name (serch patern string)</param>
        /// <param name="atticid">Attic ID (Unix Timestamp, Int32)</param>
        /// <param name="strong">Bolean, search one is true, search all is false</param>
        /// <param name="iswrite">Bolean, flag to write resource</param>
        /// <returns><see cref="WikiEngine.WikiFile.WikiFileParse"/>WikiEngine.WikiFile.WikiFileParse</returns>
        internal WikiFileParse _WikiFilesParse(WikiFileType wft, string namesspace, string file, string atticid = null, bool strong = false, bool iswrite = false)
        {
            try
            {
                WikiFileParse wfp = new WikiFileParse(wft, strong, namesspace, file, atticid, iswrite);

                if ((wfp = this.__WikiFilesParse(wfp)) == null)
                {
                    throw new WikiEngineInternalSearchErrorException(namesspace + file);
                }
                return(wfp);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #8
0
 internal void _CreateFilesList()
 {
     try
     {
         if (this._lockFs.TryEnterWriteLock((this._isOnstart) ? waitWriteFsOnStart : waitWriteFsOnProcess))
         {
             try
             {
                 DateTime dtStart = DateTime.Now;
                 this._wikiFSDict.Clear();
                 this._rootTree.ForEach(r =>
                 {
                     WikiFolderInfo wfi = new WikiFolderInfo();
                     WikiFileType type  = DokuUtil.WikiFileStringToType(WikiRequestType.None, r);
                     wfi.Files          = this._WikiFileCreateFilesList(Path.Combine(this._rootPath, r), type);
                     wfi.Dirs           = this._WikiFileCreateDictFolders(Path.Combine(this._rootPath, r), type);
                     this._wikiFSDict.Add(r, wfi);
                 });
                 this._isFsModify         = true;
                 this.waitReadFsOnProcess = ((DateTime.Now.Millisecond - dtStart.Millisecond) + 1000);
                 this.Fire_WikiFSChange(new WikiFSChangeEventArgs(this, this._wikiFSDict.Count, (this.waitReadFsOnProcess - 1000)));
             }
             finally
             {
                 try
                 {
                     this._lockFs.ExitWriteLock();
                 }
                 catch (LockRecursionException e)
                 {
                     this.Fire_ProcessError(new WikiErrorEventArgs(e, MethodBase.GetCurrentMethod().Name));
                 }
                 catch (SynchronizationLockException e)
                 {
                     this.Fire_ProcessError(new WikiErrorEventArgs(e, MethodBase.GetCurrentMethod().Name));
                 }
             }
         }
     }
     catch (Exception e)
     {
         this.Fire_ProcessError(new WikiErrorEventArgs(e, MethodBase.GetCurrentMethod().Name));
     }
 }
コード例 #9
0
 /// <summary>
 /// find pages list
 /// </summary>
 private static byte[] _WikiFindList(WikiFile wiki, WikiFileType type, string namesspace)
 {
     /*
      * bool isNameSpace = namesspace.Contains(":");
      * if (namesspace.Contains(":"))
      * {
      *  int offset = namesspace.LastIndexOf(":");
      *  namesspace = namesspace.Substring(offset, (namesspace.Length - offset));
      * }
      * if (string.IsNullOrWhiteSpace(namesspace))
      * {
      *  throw new WikiSearchException("empty");
      * }
      * Dictionary<string, List<WikiFileInfo>> dwf = null;
      *
      * switch (type)
      * {
      *  case WikiFileType.FileReadMd:
      *  case WikiFileType.FileWriteMd:
      *  case WikiFileType.FileReadBinary:
      *  case WikiFileType.FileWriteBinary:
      *  case WikiFileType.FileReadAttic:
      *  case WikiFileType.FileWriteAttic:
      *      {
      *          dwf = wiki.FindFiles(type, namesspace);
      *          break;
      *      }
      *  default:
      *      {
      *          throw new WikiNotImplementPageException(type.ToString());
      *      }
      * }
      * if (dwf == null)
      * {
      *  return null;
      * }
      * return Encoding.UTF8.GetBytes(
      *  wiki.PageListToMdString(dwf, null)
      * );
      */
     return(null);
 }
コード例 #10
0
        internal static string WikiFileTypeToString(WikiFileType type)
        {
            switch (type)
            {
            case WikiFileType.FileReadMd:
            case WikiFileType.FileWriteMd:
            {
                return(WikiFile.wikiLocalPage);
            }

            case WikiFileType.FileReadAttic:
            case WikiFileType.FileWriteAttic:
            {
                return(WikiFile.wikiLocalAttic);
            }

            case WikiFileType.FileReadBinary:
            case WikiFileType.FileWriteBinary:
            {
                return(WikiFile.wikiLocalMedia);
            }

            case WikiFileType.FileReadMeta:
            case WikiFileType.FileWriteMeta:
            {
                return(WikiFile.wikiLocalMeta);
            }

            case WikiFileType.None:
            case WikiFileType.FileUnknown:
            {
                throw new WikiEngineInternalFileTypeException("detect empty type: " + type.ToString());
            }

            default:
            {
                throw new WikiEngineInternalFileTypeException("not detect type from WikiFileType");
            }
            }
        }
コード例 #11
0
 /// <summary>
 /// Rewrite file path, change type
 /// </summary>
 /// <param name="wft">WikiFileType</param>
 /// <param name="path">file path</param>
 /// <param name="replace">replace string</param>
 /// <param name="append">append string to end</param>
 /// <returns></returns>
 internal static string WikiFilePathRewrite(WikiFileType wft, string path, string replace, string append)
 {
     if (
         (string.IsNullOrWhiteSpace(path)) ||
         (wft == WikiFileType.FileUnknown) ||
         (wft == WikiFileType.NameSpace) ||
         (wft == WikiFileType.None)
         )
     {
         return(String.Empty);
     }
     return(string.Format(
                "{0}{1}",
                path.Replace(
                    WikiFile.wikiDefaultSeparator +
                    DokuUtil.WikiFileTypeToString(wft) +
                    WikiFile.wikiDefaultSeparator,
                    WikiFile.wikiDefaultSeparator +
                    replace +
                    WikiFile.wikiDefaultSeparator
                    ),
                ((string.IsNullOrWhiteSpace(append)) ? "" : append)
                ));
 }
コード例 #12
0
        public static byte[] WebWikiRouteTree(string url, Configuration conf, WikiFileMeta wfm = null)
        {
            try
            {
                List <string> urlPart = url.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries).Skip(1).ToList();

                // Uri part, folders array
                switch (urlPart.Count)
                {
                case 0:
                {
                    // root, get home page template
                    // return Exception WikiHomePageException
                    stCore.stConsole.WriteHeader("0: Count");
                    throw new WikiHomePageException();
                }

                case 1:
                {
                    // not complette request,
                    // only WikiRequestType is set?
                    switch (CoCWebSrv._WikiGetAction(urlPart[0]))
                    {
                    default:
                    case WikiRequestType.None:
                    {
                        // get Exception Home page default (html template)
                        // return Exception WikiHomePageException
                        stCore.stConsole.WriteHeader("1: WikiRequestType.None:0");
                        _WikiGetHome(conf.WikiEngine, urlPart[0]);
                        break;
                    }

                    case WikiRequestType.List:
                    {
                        // get page list default ?
                        // return Md format txt
                        stCore.stConsole.WriteHeader("1: WikiRequestType.List:0");
                        return(_WikiGetList(conf.WikiEngine, WikiFileType.FileReadMd, String.Empty));
                    }

                    case WikiRequestType.Find:
                    {
                        // get find page default ?
                        // return Md format txt
                        stCore.stConsole.WriteHeader("1: WikiRequestType.Find:0");
                        throw new WikiSearchException("search pattern is empty");
                    }
                    }
                    break;
                }

                case 2:
                {
                    // get List/Page/Media ?
                    WikiRequestType wrt = CoCWebSrv._WikiGetAction(urlPart[0]);
                    WikiFileType    wft = CoCWebSrv._WikiGetTarget(wrt, urlPart[1]);
                    switch (wrt)
                    {
                    default:
                    case WikiRequestType.Del:
                    case WikiRequestType.Put:
                    case WikiRequestType.None:
                    {
                        // get Exception Home page default (html template)
                        // return Exception WikiHomePageException
                        stCore.stConsole.WriteHeader("2: _WikiGetHome");
                        _WikiGetHome(
                            conf.WikiEngine,
                            ((wft == WikiFileType.None) ? urlPart[1] : String.Empty)
                            );
                        break;
                    }

                    case WikiRequestType.Find:
                    {
                        // get page list default ?
                        stCore.stConsole.WriteHeader("2: _WikiFindList");
                        if (
                            ((wft == WikiFileType.None) &&
                             (string.IsNullOrWhiteSpace(urlPart[1]))) ||
                            (wft != WikiFileType.None)
                            )
                        {
                            throw new WikiSearchException("search pattern is empty");
                        }
                        return(_WikiFindList(
                                   conf.WikiEngine,
                                   ((wft == WikiFileType.None) ? WikiFileType.FileReadMd : wft),
                                   urlPart[1]
                                   ));
                    }

                    case WikiRequestType.List:
                    {
                        // get page list default ?
                        stCore.stConsole.WriteHeader("2: _WikiGetList");
                        return(_WikiGetList(
                                   conf.WikiEngine,
                                   ((wft == WikiFileType.None) ? WikiFileType.FileReadMd : wft),
                                   ((wft == WikiFileType.None) ? urlPart[1] : String.Empty)
                                   ));
                    }

                    case WikiRequestType.Get:
                    {
                        // get page/media default ? eturn start page
                        stCore.stConsole.WriteHeader("2: _WikiGetFile");
                        return(_WikiGetFile(
                                   conf.WikiEngine,
                                   ((wft == WikiFileType.None) ? WikiFileType.FileReadMd : wft),
                                   ((wft == WikiFileType.None) ? urlPart[1] : String.Empty)
                                   ));
                    }
                    }
                    break;
                }

                case 3:
                {
                    WikiRequestType wrtAct    = CoCWebSrv._WikiGetAction(urlPart[0]);
                    WikiFileType    wrtTarget = CoCWebSrv._WikiGetTarget(wrtAct, urlPart[1]);

                    if (
                        (wrtAct == WikiRequestType.None) ||
                        (wrtTarget == WikiFileType.None) ||
                        (string.IsNullOrWhiteSpace(urlPart[2])) ||
                        (!urlPart[2].Contains(":"))
                        )
                    {
                        // error request param
                        // return Exception WikiHomePageException
                        _WikiGetHome(conf.WikiEngine, urlPart[2]);
                    }

                    List <string> wikiPart = urlPart[2].Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries).ToList();

                    switch (wikiPart.Count)
                    {
                    case 0:
                    {
                        // WikiRequestType and WikiFileType is valid,
                        // namespace not found, return default
                        switch (wrtAct)
                        {
                        case WikiRequestType.Get:
                        {
                            return(_WikiGetFile(
                                       conf.WikiEngine,
                                       wrtTarget,
                                       String.Empty
                                       ));
                        }

                        case WikiRequestType.Find:
                        {
                            if (string.IsNullOrWhiteSpace(urlPart[2]))
                            {
                                throw new WikiSearchException("search pattern is empty");
                            }
                            return(_WikiFindList(
                                       conf.WikiEngine,
                                       wrtTarget,
                                       urlPart[2]
                                       ));
                        }

                        case WikiRequestType.List:
                        {
                            return(_WikiGetList(
                                       conf.WikiEngine,
                                       wrtTarget,
                                       String.Empty
                                       ));
                        }

                        case WikiRequestType.Put:
                        case WikiRequestType.Del:
                        {
                            throw new WikiErrorPageException(
                                      string.Format(
                                          "not update, name space {0} incorrected",
                                          urlPart[2]
                                          )
                                      );
                        }
                        }
                        break;
                    }

                    default:
                    {
                        // wikiPart.Count > 0
                        // namespace and page/file name
                        switch (wrtAct)
                        {
                        case WikiRequestType.Get:
                        {
                            stCore.stConsole.WriteHeader("3:default _WikiGetFile: " + urlPart[2]);
                            return(_WikiGetFile(conf.WikiEngine, wrtTarget, urlPart[2]));
                        }

                        case WikiRequestType.List:
                        {
                            stCore.stConsole.WriteHeader("3:default _WikiGetList: " + " : " + wrtTarget + " : " + urlPart[2]);
                            return(_WikiGetList(conf.WikiEngine, wrtTarget, urlPart[2]));
                        }

                        case WikiRequestType.Find:
                        {
                            stCore.stConsole.WriteHeader("3:default _WikiFindList: " + " : " + wrtTarget + " : " + urlPart[2] + " : " + wikiPart[(wikiPart.Count - 1)]);
                            int idx = (wikiPart.Count - 1);
                            if (
                                (idx < 0) ||
                                (string.IsNullOrWhiteSpace(wikiPart[idx]))
                                )
                            {
                                throw new WikiSearchException("search pattern is empty, index: " + idx);
                            }
                            return(_WikiFindList(
                                       conf.WikiEngine,
                                       wrtTarget,
                                       wikiPart[idx]
                                       ));
                        }

                        case WikiRequestType.Put:
                        case WikiRequestType.Del:
                        {
                            stCore.stConsole.WriteHeader("3:default _WikiPutFile: " + urlPart[2]);
                            if (wfm == null)
                            {
                                throw new WikiErrorPageException(
                                          string.Format(
                                              "meta data is empty, not change",
                                              urlPart[2]
                                              )
                                          );
                            }
                            if (!wfm.IsAuth)
                            {
                                throw new WikiAuthException(
                                          string.Format(
                                              "Auth error, file not change",
                                              urlPart[2]
                                              ),
                                          wfm
                                          );
                            }
                            return(_WikiPutFile(conf.WikiEngine, wrtTarget, urlPart[2], wfm));
                        }
                        }
                        break;
                    }
                    }
                    break;
                }

                default:
                {
                    _WikiGetHome(conf.WikiEngine, urlPart[0]);
                    break;
                }
                }
            }
            catch (WikiErrorPageException e)
            {
                // error page WikiErrorPageException
                conf.ILog.LogError(
                    string.Format(
                        Properties.Resources.fmtMainError,
                        string.Format(fmtClassName, "Wiki Parser"),
                        e.GetType().Name,
                        e.Message
                        )
                    );
                return(null);
            }
            catch (WikiHomePageException e)
            {
                // home page WikiHomePageException
                conf.ILog.LogError(
                    string.Format(
                        Properties.Resources.fmtMainError,
                        string.Format(fmtClassName, "Wiki Parser"),
                        e.GetType().Name,
                        e.Message
                        )
                    );
                return(null);
            }
#if DEBUG
            catch (Exception e)
            {
                conf.ILog.LogError(
                    string.Format(
                        Properties.Resources.fmtMainError,
                        string.Format(fmtClassName, "Wiki Parser"),
                        e.GetType().Name,
                        e.Message
                        )
                    );
#else
            catch (Exception)
            {
#endif
                return(null);
            }
            return(null);
        }
コード例 #13
0
        /// <summary>
        /// ToString method from <see cref="WikiEngine.WikiFolderInfo"/>WikiEngine.WikiFolderInfo to MarkDown
        /// Page/Media/Attic List
        /// </summary>
        /// <param name="wfi"><see cref="WikiEngine.WikiFolderInfo"/>WikiEngine.WikiFolderInfo input</param>
        /// <param name="sb">StringBuilder instance or null</param>
        /// <param name="type"><see cref="WikiEngine.WikiFileType"/>WikiEngine.WikiFileType, if this equals WikiFileType.FileReadAttic, return only date from attic</param>
        /// <returns>String or String.Empty</returns>
        public string ResourceListToMdString(WikiFolderInfo wfi, StringBuilder sb = null, WikiFileType type = WikiFileType.None)
        {
            Action         act;
            WikiFileAction wfa = new WikiFileAction(sb);

            wfa.IsAllFiles = true;

            switch (type)
            {
            // Attic date and time list to Md string
            case WikiFileType.FileReadAttic:
            case WikiFileType.FileWriteAttic:
            {
                act = (Action)(() => this._WikiFileActionRecursive(wfi, wfa, this._ActionAtticDateList));
                break;
            }

            default:
            {
                act = (Action)(() => this._WikiFileActionRecursive(wfi, wfa, this._ActionResourceList));
                break;
            }
            }
            string sOut = this._ToMd(
                (object)new Object(),
                act,
                wfa.IsSBuilder,
                wfa.SBuilder
                );

            return(string.Format(
                       Properties.ResourceWikiEngine.ListFormatPageStatistic,
                       sOut,
                       ((string.IsNullOrWhiteSpace(wfi.SearchPatern)) ? wfi.NameSpace : wfi.SearchPatern),
                       wfa.ConutDirs,
                       wfa.ConutFiles,
                       Environment.NewLine
                       ));
        }
コード例 #14
0
        /// <summary>
        /// get page/media/attic/meta
        /// </summary>
        private byte[] _WikiGetFile(WikiFileType wft, string namesspace)
        {
            try
            {
                WikiData      wd  = null;
                WikiFileParse wfp = null;

                if ((wfp = (WikiFileParse)this._WikiFilesParse(
                         wft, namesspace, null, null, true
                         )) == null)
                {
                    throw new WikiEngineInternalNameSpaceErrorException(
                              string.Format(
                                  Properties.ResourceWikiEngine.fmtErrorMapTree,
                                  MethodBase.GetCurrentMethod().Name,
                                  namesspace,
                                  wft.ToString()
                                  )
                              );
                }
                switch (wfp.FolderType)
                {
                default:
                case WikiFileType.FileReadMd:
                case WikiFileType.FileWriteMd:
                case WikiFileType.FileReadBinary:
                case WikiFileType.FileWriteBinary:
                {
                    wd = this._GetFile(wfp);
                    break;
                }

                case WikiFileType.FileReadAttic:
                case WikiFileType.FileWriteAttic:
                {
                    wd = this._GetFileFromAttic(wfp);
                    break;
                }

                case WikiFileType.FileReadMeta:
                {
                    return(Encoding.UTF8.GetBytes(
                               this.MetaListToMdString(
                                   this._GetFileMeta(wfp)
                                   )
                               ));
                }

                case WikiFileType.FileWriteMeta:
                {
                    throw new WikiEngineNotImplementPageException(
                              string.Format(
                                  Properties.ResourceWikiEngine.fmtErrorMapTree,
                                  MethodBase.GetCurrentMethod().Name,
                                  namesspace,
                                  wfp.FolderType.ToString()
                                  )
                              );
                }
                }
                if (
                    (wd == null) ||
                    (wd.FileContent == null) ||
                    (wd.FileContent.Length == 0)
                    )
                {
                    throw new WikiEngineInternalSearchEmptyException(
                              string.Format(
                                  Properties.ResourceWikiEngine.fmtErrorMapTree,
                                  MethodBase.GetCurrentMethod().Name,
                                  namesspace,
                                  wfp.FolderType.ToString()
                                  )
                              );
                }
                return(wd.FileContent);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #15
0
        /// <summary>
        /// internal Uri/Namespace parse
        /// </summary>
        /// <param name="wfp"></param>
        /// <returns><see cref="WikiFile.WikiFileParse"/>WikiFile.WikiFileParse</returns>
        internal WikiFileParse __WikiFilesParse(WikiFileParse wfp)
        {
            try
            {
                bool checkNs = !string.IsNullOrWhiteSpace(wfp.NameSpacePatern),
                     checkFn = !string.IsNullOrWhiteSpace(wfp.SearchPatern);

                if ((!checkNs) && (!checkFn))
                {
                    throw new WikiEngineInternalNameSpaceErrorException(
                              ((checkNs) ? wfp.NameSpacePatern : "") +
                              ((checkFn) ? wfp.SearchPatern : "")
                              );
                }
                else if ((checkNs) && (!checkFn))
                {
                    if (!wfp.IsNameSpaceValid)
                    {
                        wfp.SearchPatern    = wfp.NameSpacePatern;
                        wfp.NameSpacePatern = ":";
                        checkNs             = !checkNs;
                        checkFn             = !checkFn;
                    }
                }
                else if ((!checkNs) && (checkFn))
                {
                    if (!wfp.IsSearchPaternValid)
                    {
                        wfp.NameSpacePatern = wfp.SearchPatern;
                        wfp.SearchPatern    = String.Empty;
                        checkNs             = !checkNs;
                        checkFn             = !checkFn;
                    }
                }
                if (checkNs)
                {
                    WikiFileType dwft = DokuUtil.WikiFileStringToDefaultType(wfp.NameSpacePatern, wfp.IsWriteOperation);
                    switch (dwft)
                    {
                    case WikiFileType.None:
                    case WikiFileType.FileUnknown:
                    {
                        switch (wfp.FolderType)
                        {
                        case WikiFileType.None:
                        case WikiFileType.FileUnknown:
                        {
                            throw new WikiEngineInternalFileTypeException(
                                      ((checkNs) ? wfp.NameSpacePatern : "") +
                                      ((checkFn) ? wfp.SearchPatern : "")
                                      );
                        }

                        default:
                        {
                            break;
                        }
                        }
                        break;
                    }

                    case WikiFileType.NameSpace:
                    {
                        /*
                         * // strong check files
                         * if (!checkFn)
                         * {
                         *  throw new WikiEngineInternalNameSpaceErrorException(
                         *      ((checkFn) ? wfp.SearchPatern : "")
                         *  );
                         * }
                         */
                        break;
                    }

                    default:
                    {
                        switch (wfp.FolderType)
                        {
                        case WikiFileType.None:
                        case WikiFileType.FileUnknown:
                        {
                            wfp.FolderType = dwft;
                            break;
                        }

                        default:
                        {
                            break;
                        }
                        }
                        break;
                    }
                    }
                }
                switch (wfp.FolderType)
                {
                case WikiFileType.None:
                case WikiFileType.FileUnknown:
                {
                    throw new WikiEngineInternalFileTypeException(
                              ((checkNs) ? wfp.NameSpacePatern : "") +
                              ((checkFn) ? wfp.SearchPatern : "")
                              );
                }

                case WikiFileType.FileReadAttic:
                case WikiFileType.FileWriteAttic:
                {
                    this.__WikiFilesParseAtticExtension(ref wfp, checkNs, checkFn, atticExtension);
                    break;
                }

                case WikiFileType.FileReadMeta:
                case WikiFileType.FileWriteMeta:
                {
                    this.__WikiFilesParseMetaExtension(ref wfp, checkNs, checkFn, metaExtension);
                    break;
                }

                default:
                {
                    break;
                }
                }

                // Cache read request
                wfp.CacheId = ((this._isCacheEnable) ?
                               _WikiFileCacheId(
                                   wfp.FolderType,
                                   string.Concat(
                                       ((checkNs) ? wfp.NameSpacePatern : "-"),
                                       (((!checkNs) && (checkFn)) ? wfp.SearchPatern : "-")
                                       )
                                   ) :
                               String.Empty
                               );
                if ((this._isCacheEnable) && ((wfp.FolderInfo = _WikiFileCacheRead(wfp.CacheId)) != null))
                {
                    return(wfp);
                }
                // End Cache

                if ((wfp.UriPart = wfp.NameSpacePatern
                                   .Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries)
                                   .ToList <string>()) == null)
                {
                    throw new WikiEngineInternalSearchOkException();
                }
                if (
                    (!checkFn) &&
                    (wfp.UriPart.Count > 1)
                    )
                {
                    wfp.SearchPatern = wfp.UriPart[(wfp.UriPart.Count - 1)];
                    wfp.UriPart.RemoveAt(wfp.UriPart.Count - 1);
                }
                return(wfp);
            }
            catch (WikiEngineInternalSearchOkException)
            {
                return(null);
            }
            catch (Exception e)
            {
                this.Fire_ProcessError(new WikiErrorEventArgs(e, MethodBase.GetCurrentMethod().Name));
                return(null);
            }
        }
コード例 #16
0
        /// <summary>
        /// put page/media
        /// </summary>
        private byte[] _WikiPutFile(WikiFileType wft, string namesspace, WikiFileMeta wfm = null)
        {
            try
            {
                WikiData      wd  = null;
                WikiFileParse wfp = null;

                if (wfm == null)
                {
                    throw new WikiEnginePutException(
                              string.Format(
                                  Properties.ResourceWikiEngine.fmtErrorMapTree,
                                  MethodBase.GetCurrentMethod().Name,
                                  namesspace,
                                  wft.ToString()
                                  )
                              );
                }
                if ((wfp = (WikiFileParse)this._WikiFilesParse(
                         wft, namesspace, null, null, true
                         )) == null)
                {
                    throw new WikiEngineInternalNameSpaceErrorException(
                              string.Format(
                                  Properties.ResourceWikiEngine.fmtErrorMapTree,
                                  MethodBase.GetCurrentMethod().Name,
                                  namesspace,
                                  wft.ToString()
                                  )
                              );
                }
                if ((wfp.IsNameSpaceValid) && (!wfp.IsNameSpaceOnly))
                {
                    switch (wfp.FolderType)
                    {
                    case WikiFileType.FileWriteMd:
                    case WikiFileType.FileWriteBinary:
                    {
                        break;
                    }

                    case WikiFileType.FileWriteAttic:
                    case WikiFileType.FileWriteMeta:
                    {
                        throw new WikiEngineNotImplementPageException(
                                  string.Format(
                                      Properties.ResourceWikiEngine.fmtErrorMapTree,
                                      MethodBase.GetCurrentMethod().Name,
                                      namesspace,
                                      wfp.FolderType.ToString()
                                      )
                                  );
                    }

                    default:
                    case WikiFileType.FileReadMd:
                    case WikiFileType.FileReadMeta:
                    case WikiFileType.FileReadAttic:
                    case WikiFileType.FileReadBinary:
                    {
                        throw new WikiEngineInternalFileTypeException(
                                  string.Format(
                                      Properties.ResourceWikiEngine.fmtErrorMapTreePut,
                                      MethodBase.GetCurrentMethod().Name,
                                      wfp.FolderType.ToString(),
                                      namesspace
                                      )
                                  );
                    }
                    }
                }
                else
                {
                    throw new WikiEngineInternalNameSpaceErrorException(
                              string.Format(
                                  Properties.ResourceWikiEngine.fmtErrorMapTreeNameSpace,
                                  MethodBase.GetCurrentMethod().Name,
                                  wfp.FolderType.ToString(),
                                  namesspace
                                  )
                              );
                }
                if (
                    ((wd = this._PutFile(wfp, null, wfm)) == null) ||
                    (wd.FileContent == null) ||
                    (wd.FileContent.Length == 0)
                    )
                {
                    throw new WikiEngineInternalSearchEmptyException(
                              string.Format(
                                  Properties.ResourceWikiEngine.fmtErrorMapTree,
                                  MethodBase.GetCurrentMethod().Name,
                                  namesspace,
                                  wfp.FolderType.ToString()
                                  )
                              );
                }
                return(wd.FileContent);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #17
0
        /// <summary>
        /// find pages list
        /// </summary>
        private byte[] _WikiFindList(WikiFileType wft, string namesspace)
        {
            WikiFileParse  wfp = null;
            WikiFolderInfo wfi = null;

            try
            {
                if ((wfp = (WikiFileParse)this._WikiFilesParse(
                         wft, namesspace, null, null, false
                         )) == null)
                {
                    throw new WikiEngineInternalNameSpaceErrorException(
                              string.Format(
                                  Properties.ResourceWikiEngine.fmtErrorMapTree,
                                  MethodBase.GetCurrentMethod().Name,
                                  namesspace,
                                  wft.ToString()
                                  )
                              );
                }
                switch (wfp.FolderType)
                {
                case WikiFileType.FileReadMd:
                case WikiFileType.FileWriteMd:
                case WikiFileType.FileReadBinary:
                case WikiFileType.FileWriteBinary:
                case WikiFileType.FileReadAttic:
                case WikiFileType.FileWriteAttic:
                {
                    if ((wfi = (WikiFolderInfo)this._FindFiles(wfp)) == null)
                    {
                        throw new WikiEngineInternalSearchEmptyException(
                                  string.Format(
                                      Properties.ResourceWikiEngine.fmtErrorMapTree,
                                      MethodBase.GetCurrentMethod().Name,
                                      namesspace,
                                      wfp.FolderType.ToString()
                                      )
                                  );
                    }
                    break;
                }

                default:
                {
                    throw new WikiEngineNotImplementPageException(
                              string.Format(
                                  Properties.ResourceWikiEngine.fmtErrorMapTree,
                                  MethodBase.GetCurrentMethod().Name,
                                  namesspace,
                                  wfp.FolderType.ToString()
                                  )
                              );
                }
                }
                return(Encoding.UTF8.GetBytes(
                           this.ResourceListToMdString(wfi, null, wfp.FolderType)
                           ));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #18
0
        internal Dictionary <string, WikiFolderInfo> _WikiFileCreateDictFolders(string dir, WikiFileType type)
        {
            Dictionary <string, WikiFolderInfo> foldrDic = new Dictionary <string, WikiFolderInfo>();

            foreach (string d in Directory.GetDirectories(dir))
            {
                WikiFolderInfo wfi = new WikiFolderInfo();
                wfi.Files = _WikiFileCreateFilesList(d, type);
                wfi.Dirs  = _WikiFileCreateDictFolders(d, type);
                d.Substring(this._rootPath.Length, (d.Length - this._rootPath.Length))
                .Split(new string[] { WikiFile.wikiDefaultSeparator }, StringSplitOptions.RemoveEmptyEntries)
                .ToArray <string>()
                .Skip(1)
                .ToList <string>()
                .ForEach(o =>
                {
                    wfi.NameSpace = String.Concat(wfi.NameSpace, o, ":");
                });

                foldrDic.Add(Path.GetFileName(d), wfi);
            }
            return(foldrDic);
        }
コード例 #19
0
        /// <summary>
        /// Wiki Route tree (Web)
        /// return requested resource from wiki file system.
        /// </summary>
        /// <example>
        /// Uri: /wiki/get/pages|attic|media|meta/clan:test1
        /// Uri: /wiki/put/pages|attic|media/clan:test1
        /// Uri: /wiki/del/pages|attic|media/clan:test1
        /// Uri: /wiki/list/pages|attic|media/clan:
        /// Uri: /wiki/find/part-of-serch-page-name
        /// enum <see cref="WikiEngine.WikiRequestType"/>WikiEngine.WikiRequestType: get|put|del|list|find
        /// enum <see cref="WikiEngine.WikiFileType"/>WikiEngine.WikiFileType: pages|attic|media|meta
        /// </example>
        /// <remarks>
        /// Example routing Uri:
        ///
        /// "/wiki/get/pages/clan:test1" OK
        /// "/wiki/get/clan:test1" OK
        /// "/wiki/clan:test1" -> HomeException
        /// "/wiki/clan:" -> HomeException
        /// "/wiki/" -> HomeException (redirect)
        ///
        /// "/wiki/list/pages/clan:" OK
        /// "/wiki/list/clan:" OK (default pages)
        /// "/wiki/list/" OK (default pages and default namespace)
        ///
        /// "/wiki/list/media/clan:" OK
        /// "/wiki/list/media/" OK (default namespace)
        ///
        /// "/wiki/find/pages/tes" OK
        /// "/wiki/find/media/tes" OK
        /// "/wiki/find/attic/tes" OK
        /// "/wiki/find/tes" OK (default pages and default namespace)
        ///
        /// </remarks>
        /// <exception cref="WikiEngine.Exceptions.WikiEngineAuthException">WikiEngineAuthException</exception>
        /// <exception cref="WikiEngine.Exceptions.WikiEngineSearchException">WikiEngineSearchException</exception>
        /// <exception cref="WikiEngine.Exceptions.WikiEngineHomePageException">WikiEngineHomePageException</exception>
        /// <exception cref="WikiEngine.Exceptions.WikiEngineErrorPageException">WikiEngineErrorPageException</exception>
        /// <exception cref="WikiEngine.Exceptions.WikiEngineNotImplementPageException">WikiEngineNotImplementPageException</exception>
        /// <param name="url">given raw url requested</param>
        /// <param name="wfm"><see cref="WikiEngine.WikiFileMeta"/>WikiEngine.WikiFileMeta</param>
        /// <returns>byte[] from requested source</returns>
        public byte [] RouteTree(string url, WikiFileMeta wfm = null)
        {
            try
            {
                List <string> urlPart = url.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries).Skip(1).ToList();

                // Uri part, folders array
                switch (urlPart.Count)
                {
                case 0:
                {
                    // root, get home page template
                    // return Exception WikiHomePageException
                    Console.WriteLine("0: Count");
                    throw new WikiEngine.Exceptions.WikiEngineHomePageException();
                }

                case 1:
                {
                    // command line: (/get | /put | /del | /list)
                    // not complette request,
                    // only WikiRequestType is set?
                    switch (DokuUtil.WikiFileStringToMethod(urlPart[0]))
                    {
                    default:
                    case WikiRequestType.None:
                    {
                        // get Exception Home page default (html template)
                        // return Exception WikiHomePageException
                        Console.WriteLine("1: WikiRequestType.None:0");
                        if (!string.IsNullOrWhiteSpace(urlPart[0]))
                        {
                            if (urlPart[0].EndsWith(":"))
                            {
                                return(_WikiGetList(
                                           WikiFileType.FileReadMd,
                                           urlPart[0]
                                           ));
                            }
                            else if (urlPart[0].Contains(":"))
                            {
                                return(_WikiGetFile(
                                           WikiFileType.FileReadMd,
                                           urlPart[0]
                                           ));
                            }
                        }
                        throw new WikiEngine.Exceptions.WikiEngineHomePageException(urlPart[0]);
                    }

                    case WikiRequestType.List:
                    {
                        // get page list default ?
                        // return Md format txt
                        Console.WriteLine("1: WikiRequestType.List:0");
                        return(_WikiGetList(WikiFileType.FileReadMd, String.Empty));
                    }

                    case WikiRequestType.Find:
                    {
                        // get find page default ?
                        // return Md format txt
                        Console.WriteLine("1: WikiRequestType.Find:0");
                        throw new WikiEngineSearchException("search pattern is empty");
                    }
                    }
                }

                case 2:
                {
                    // command line: /get (/pages | /media | /attic | /meta)
                    // get List/Page/Media ?
                    string          nssource = String.Empty;
                    WikiRequestType wrt      = DokuUtil.WikiFileStringToMethod(urlPart[0]);
                    WikiFileType    wft      = DokuUtil.WikiFileStringToType(wrt, urlPart[1]);
                    switch (wrt)
                    {
                    case WikiRequestType.None:
                    {
                        if (wft == WikiFileType.None)
                        {
                            if ((wft = DokuUtil.WikiFileStringToType(wrt, urlPart[0])) != WikiFileType.None)
                            {
                                wrt      = WikiRequestType.Get;
                                nssource = urlPart[1];
                            }
                        }
                        break;
                    }

                    default:
                    {
                        if (wft == WikiFileType.None)
                        {
                            nssource = urlPart[1];
                            wft      = WikiFileType.FileReadMd;
                        }
                        else
                        {
                            nssource = this._defaultNameSpace;
                        }
                        break;
                    }
                    }
                    switch (wrt)
                    {
                    default:
                    case WikiRequestType.Del:
                    case WikiRequestType.Put:
                    case WikiRequestType.None:
                    {
                        // get Exception Home page default (html template)
                        // return Exception WikiHomePageException
                        Console.WriteLine("2: _WikiGetHome");
                        throw new WikiEngine.Exceptions.WikiEngineHomePageException(
                                  nssource
                                  );
                    }

                    case WikiRequestType.Find:
                    {
                        // find pages list (default from nssource)
                        Console.WriteLine("2: _WikiFindList");
                        return(_WikiFindList(wft, nssource));
                    }

                    case WikiRequestType.List:
                    {
                        // get pages list (default from nssource)
                        Console.WriteLine("2: _WikiGetList");
                        return(_WikiGetList(wft, nssource));
                    }

                    case WikiRequestType.Get:
                    {
                        // get page/media resource (default from nssource)
                        Console.WriteLine("2: _WikiGetFile");
                        return(_WikiGetFile(wft, nssource));
                    }
                    }
                }

                case 3:
                {
                    WikiRequestType wrtAct    = DokuUtil.WikiFileStringToMethod(urlPart[0]);
                    WikiFileType    wrtTarget = DokuUtil.WikiFileStringToType(wrtAct, urlPart[1]);

                    if (
                        (wrtAct == WikiRequestType.None) ||
                        (wrtTarget == WikiFileType.None) ||
                        (string.IsNullOrWhiteSpace(urlPart[2])) ||
                        (
                            (wrtAct != WikiRequestType.Find) &&
                            (!urlPart[2].Contains(":"))
                        )
                        )
                    {
                        // error request param
                        // return Exception WikiHomePageException
                        throw new WikiEngineHomePageException(urlPart[2]);
                    }

                    List <string> wikiPart = urlPart[2].Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries).ToList();

                    switch (wikiPart.Count)
                    {
                    case 0:
                    {
                        // WikiRequestType and WikiFileType is valid,
                        // namespace not found, return default
                        switch (wrtAct)
                        {
                        case WikiRequestType.Get:
                        {
                            return(_WikiGetFile(wrtTarget, this._defaultNameSpace));
                        }

                        case WikiRequestType.List:
                        {
                            return(_WikiGetList(wrtTarget, this._defaultNameSpace));
                        }

                        case WikiRequestType.Find:
                        {
                            if (string.IsNullOrWhiteSpace(urlPart[2]))
                            {
                                throw new WikiEngineSearchException(
                                          string.Format(
                                              Properties.ResourceWikiEngine.txtErrorSearchPaternEmpty,
                                              "0"
                                              )
                                          );
                            }
                            return(_WikiFindList(wrtTarget, urlPart[2]));
                        }

                        case WikiRequestType.Put:
                        case WikiRequestType.Del:
                        {
                            throw new WikiEngineErrorPageException(
                                      string.Format(
                                          Properties.ResourceWikiEngine.fmtErrorNSError,
                                          wrtAct.ToString(),
                                          urlPart[2]
                                          )
                                      );
                        }
                        }
                        break;
                    }

                    default:
                    {
                        // wikiPart.Count > 0
                        // namespace and page/file name
                        switch (wrtAct)
                        {
                        case WikiRequestType.Get:
                        {
                            Console.WriteLine("3:default _WikiGetFile: " + urlPart[2]);
                            return(_WikiGetFile(wrtTarget, urlPart[2]));
                        }

                        case WikiRequestType.List:
                        {
                            Console.WriteLine("3:default _WikiGetList: " + " : " + wrtTarget + " : " + urlPart[2]);
                            return(_WikiGetList(wrtTarget, urlPart[2]));
                        }

                        case WikiRequestType.Find:
                        {
                            Console.WriteLine("3:default _WikiFindList: " + " : " + wrtTarget + " : " + urlPart[2] + " : " + wikiPart[(wikiPart.Count - 1)]);
                            int idx = (wikiPart.Count - 1);
                            if (
                                (idx < 0) ||
                                (string.IsNullOrWhiteSpace(wikiPart[idx]))
                                )
                            {
                                throw new WikiEngineSearchException(
                                          string.Format(
                                              Properties.ResourceWikiEngine.txtErrorSearchPaternEmpty,
                                              idx
                                              )
                                          );
                            }
                            return(_WikiFindList(wrtTarget, wikiPart[idx]));
                        }

                        case WikiRequestType.Put:
                        case WikiRequestType.Del:
                        {
                            Console.WriteLine("3:default _WikiPutFile: " + urlPart[2]);
                            if (wfm == null)
                            {
                                throw new WikiEngineAuthException(
                                          string.Format(
                                              Properties.ResourceWikiEngine.fmtErrorMetaEmpty,
                                              urlPart[2]
                                              )
                                          );
                            }
                            if (!wfm.IsAuth)
                            {
                                throw new WikiEngineAuthException(
                                          string.Format(
                                              Properties.ResourceWikiEngine.fmtErrorAuthEmpty,
                                              urlPart[2]
                                              ),
                                          wfm
                                          );
                            }
                            return(this._WikiPutFile(wrtTarget, urlPart[2], wfm));
                        }
                        }
                        break;
                    }
                    }
                    break;
                }

                default:
                {
                    throw new WikiEngineHomePageException(urlPart[0]);
                }
                }
            }
            catch (Exception e)
            {
                if (!this._isMapExceptions)
                {
                    throw e;
                }
            }
            return(null);
        }
コード例 #20
0
        /// <summary>
        /// get page/media
        /// </summary>
        private static byte[] _WikiGetFile(stDokuWiki.WikiEngine.WikiFile wiki, WikiFileType type, string namesspace)
        {
            WikiData wd = null;

            switch (namesspace.Contains(":"))
            {
            case true:
            {
                switch (type)
                {
                default:
                case WikiFileType.FileReadMd:
                case WikiFileType.FileWriteMd:
                {
                    wd = wiki.GetFile(namesspace);
                    break;
                }

                case WikiFileType.FileReadBinary:
                case WikiFileType.FileWriteBinary:
                {
                    wd = wiki.GetFile(namesspace);
                    break;
                }

                case WikiFileType.FileReadAttic:
                case WikiFileType.FileWriteAttic:
                {
                    wd = wiki.GetFileFromAttic(namesspace, "0");
                    break;
                }

                case WikiFileType.FileReadMeta:
                {
                    return(Encoding.UTF8.GetBytes(
                               wiki.MetaListToMdString(
                                   wiki.GetFileMeta(namesspace)
                                   )
                               ));
                }

                case WikiFileType.FileWriteMeta:
                {
                    throw new WikiNotImplementPageException(WikiFileType.FileWriteMeta.ToString());
                }
                }
                break;
            }

            /// operation default
            case false:
            {
                switch (type)
                {
                default:
                case WikiFileType.FileReadMd:
                case WikiFileType.FileWriteMd:
                {
                    wd = wiki.GetFile(":start");
                    break;
                }

                case WikiFileType.FileReadBinary:
                case WikiFileType.FileWriteBinary:
                {
                    wd = wiki.GetFile(":logo.png");
                    break;
                }

                case WikiFileType.FileReadAttic:
                case WikiFileType.FileWriteAttic:
                {
                    // TODO: get last from attic
                    wd = wiki.GetFileFromAttic(":start", "0");
                    break;
                }

                case WikiFileType.FileReadMeta:
                {
                    throw new WikiNotImplementPageException(WikiFileType.FileReadMeta.ToString());
                }

                case WikiFileType.FileWriteMeta:
                {
                    throw new WikiNotImplementPageException(WikiFileType.FileWriteMeta.ToString());
                }
                }
                break;
            }
            }
            if (
                (wd == null) ||
                (wd.FileContent == null) ||
                (wd.FileContent.Length == 0)
                )
            {
                return(null);
            }
            return(wd.FileContent);
        }
コード例 #21
0
        /// <summary>
        /// put page/media
        /// </summary>
        private static byte[] _WikiPutFile(stDokuWiki.WikiEngine.WikiFile wiki, WikiFileType type, string namesspace, WikiFileMeta wfm = null)
        {
            WikiData wd = null;

            switch (namesspace.Contains(":"))
            {
            case true:
            {
                switch (type)
                {
                case WikiFileType.FileWriteMd:
                {
                    if (wfm == null)
                    {
                        throw new WikiErrorPageException(
                                  string.Format(
                                      "not write {0}, input data is empty",
                                      namesspace
                                      )
                                  );
                    }
                    wd = wiki.PutFile(namesspace, null, wfm);
                    break;
                }

                case WikiFileType.FileWriteBinary:
                {
                    wd = wiki.GetFile(namesspace);
                    break;
                }

                case WikiFileType.FileWriteAttic:
                {
                    throw new WikiNotImplementPageException(WikiFileType.FileWriteAttic.ToString());
                }

                case WikiFileType.FileWriteMeta:
                {
                    throw new WikiNotImplementPageException(WikiFileType.FileWriteMeta.ToString());
                }

                default:
                case WikiFileType.FileReadMd:
                case WikiFileType.FileReadMeta:
                case WikiFileType.FileReadAttic:
                case WikiFileType.FileReadBinary:
                {
                    throw new WikiErrorPageException(
                              string.Format(
                                  "type set is read, not support for this version, name space: {0}",
                                  namesspace
                                  )
                              );
                }
                }
                break;
            }

            case false:
            {
                throw new WikiErrorPageException(
                          string.Format(
                              "not valid name space: {0}",
                              namesspace
                              )
                          );
            }
            }
            if (
                (wd == null) ||
                (wd.FileContent == null) ||
                (wd.FileContent.Length == 0)
                )
            {
                return(null);
            }
            return(wd.FileContent);
        }