private string MovePageStubs(XDoc spaceManifest, string spaceRoot, string parentPagePath, RemotePageSummary confluenceRemotePageSummary,
           string pageName, string pageTitle, ACConverterPageInfo parentPage)
        {
            RemotePage confluenceRemotePage = _confluenceService.GetPage(confluenceRemotePageSummary.id);
            string tinyUrl = null;

            if(_rpcclient != null) {
                CFRpcExtensions rpcExt = new CFRpcExtensions(_rpcclient);
                tinyUrl = rpcExt.GetTinyUrlForPageId(confluenceRemotePageSummary.id.ToString());
            }

            string pagePath = null;

            //If PageName not null use it, else use Confluence page title.
            if (pageName == null)
            {
                pageName = confluenceRemotePage.title;
            }

            pagePath = pageName;
            if (parentPagePath != null)
            {
                pagePath = parentPagePath + Utils.DoubleUrlEncode("/" + pagePath);
            }

            //If the page title is too long it gets saved as {spaceroot}/misc/{pageid} with the page title set
            if(pagePath.Length > MaxLengthOfPageTitle) {
                pagePath = Utils.DoubleUrlEncode(string.Format(@"{0}/misc/{1}", spaceRoot, confluenceRemotePage.id));
                if(string.IsNullOrEmpty(pageTitle)) {
                    pageTitle = pageName;
                }
                Log.WarnFormat("Page title longer than {0}. Will be placed into {1}. Title: {2}", MaxLengthOfPageTitle, pagePath, pageTitle);
            }

            Plug postPageDekiPlug = (confluenceRemotePage.creator == null) ? _dekiPlug :
                GetPlugForConvertedUser(confluenceRemotePage.creator);

            Log.TraceFormat("Creating page stub in space '{0}'", confluenceRemotePage.space);

            string mtPageUrl;

            // modified date string, according to:
            /* http://developer.mindtouch.com/en/ref/MindTouch_API/POST%3apages%2f%2f%7Bpageid%7D%2f%2fcontents
             * should be formatted as:
             * the edit timestamp - yyyyMMddHHmmss or yyyy-MM-ddTHH:mm:ssZ
             */

            int dekiPageId = CreateDekiPage(postPageDekiPlug, pagePath, pageTitle, confluenceRemotePage.modified, "",
                out mtPageUrl);

            if (dekiPageId == -1)
            {

                //TODO (maxm): page failure needs to be recorded and steps that depend 
                // on it such as attachments and children should be skipped
                return string.Empty;
            }
            ACConverterPageInfo pageInfo = new ACConverterPageInfo(confluenceRemotePage, spaceRoot, mtPageUrl, pagePath, dekiPageId, pageTitle, tinyUrl, parentPage);

            Utils.PersistPageInfo(pageInfo);

            //Confluence view page permission is inherited. Save they to use later in MovePermissions.
            SavePageViewPermissions(pageInfo);

            RemotePageSummary[] childPages = _confluenceService.GetChildren(confluenceRemotePage.id);
            foreach (RemotePageSummary childPageSummary in childPages)
            {
                MovePageStubs(spaceManifest, spaceRoot, pagePath, childPageSummary, null, null, pageInfo);
            }

            SaveCommentsLinks(spaceManifest, pageInfo.ConfluencePage.space, pageInfo.ConfluencePage.id, mtPageUrl);

            MoveAttachments(spaceManifest, pageInfo.DekiPageId,pageInfo.ConfluencePage.id);

            LogPageConversion(spaceManifest, pageInfo);

            return pagePath;
        }
Esempio n. 2
0
 public string GetTinyUrlForPage(string ConfluenceXMLRPCUrl,string confluenceUserName, string confluenceUserPassword, string pageId)
 {
     CFRpcClient client = new CFRpcClient(ConfluenceXMLRPCUrl, confluenceUserName, confluenceUserPassword);
     CFRpcExtensions rpcExt = new CFRpcExtensions(client);
     //List<CFTeamLabels> teamLabels = rpcExt.GetSpaceTeamLables("ds");
     //string spaceTeamLabel = teamLabels[0].Label;
     return rpcExt.GetTinyUrlForPageId(pageId);            
 }