Exemple #1
0
        //--- Class Methods ---
        public static bool Convert(string confluenceXMLRPCUrl, string confluenceAPIUrl, string confluenceUserName, string confluenceUserPassword, string dreamAPI,
                                   string dekiUserName, string dekiUserPassword, bool compatibleConvertUserPermissions,
                                   List <string> spacesToConvert, bool processNewsPages, bool processPersonalSpaces, string fallbackSpacePrefix)
        {
            using (ACConverter converter = new ACConverter()) {
                try {
                    Log.Info("Connecting to MindTouch API");
                    converter.ConnectToDeki(dreamAPI, dekiUserName, dekiUserPassword);
                } catch (DreamResponseException dre) {
                    Log.Fatal("Can not connect to MindTouch API server.", dre);
                    return(false);
                }

                if (converter._connectedToDeki)
                {
                    Log.Info("Successfully connected to MindTouch");
                }
                else
                {
                    Log.Fatal("Can not connect to MindTouch server.");
                    return(false);
                }

                try {
                    Log.Info("Connecting to Confluence API");
                    converter.ConnectToConfluence(confluenceAPIUrl, confluenceUserName, confluenceUserPassword);
                } catch (System.Net.WebException e) {
                    Log.ErrorExceptionFormat(e, "Can not connect to Confluence");
                    return(false);
                } catch (System.Web.Services.Protocols.SoapException e) {
                    if ((e.Detail != null) && (e.Detail.OuterXml != null))
                    {
                        Log.Fatal("Can not connect to Confluence: " + e.Detail.OuterXml, e);
                    }
                    else
                    {
                        Log.Fatal("Can not connect to Confluence", e);
                    }
                    return(false);
                }

                // The base URL needs to be set globally in a static variable so that macros can access it.
                // For example so the "include" macro knows if a given link is for a page on the current confluence site or not.
                ConfluenceBaseURL = converter._confluenceService.GetServerInfo().baseUrl;

                Log.Info("Connecting to Confluence XMLRPC API");
                if (!converter.ConnectToConfluenceRPC(confluenceXMLRPCUrl, confluenceUserName, confluenceUserPassword))
                {
                    Log.Fatal("Can not connect to Confluence XML RPC server.");
                }

                Log.Info("Successfully connected to Confluence");
                RemoteServerInfo confluenceServerInfo = converter._confluenceService.GetServerInfo();
                Log.InfoFormat("Confluence version: {0}.{1}.{2}", confluenceServerInfo.majorVersion.ToString(),
                               confluenceServerInfo.minorVersion.ToString(), confluenceServerInfo.patchLevel.ToString());

                converter.Convert(new XUri(confluenceServerInfo.baseUrl), compatibleConvertUserPermissions, processNewsPages, spacesToConvert, processPersonalSpaces, fallbackSpacePrefix);
                return(true);
            }
        }