Example #1
0
		private void ShowMain()
		{
			if (CheckForConfigurationFormatUpgrade())
				return;

			string config = ConfigurationManager.AppSettings["FederationNamespaceMapFile"];
			string mappedConfig = (config == null ? null : MapPath(config));
			ConfigurationChecker checker = new ConfigurationChecker(
				config,
				mappedConfig);

			checker.Check();
			checker.WriteStoplightTo(UIResponse);

			UIResponse.WriteDivider();

			Federation aFederation = null;
			try
			{
                FlexWikiWebApplication application = new FlexWikiWebApplication(mappedConfig, new LinkMaker("")); 
				aFederation = new Federation(application);
			}
			catch (Exception)
			{
			}

			if (aFederation != null)
				ShowFederationInfo(aFederation);
		}
Example #2
0
        public void Check()
        {
            _results.Clear();
            FederationConfiguration config = null;

            CheckPluginTypes();

            if (CheckConfigurationFileSetting())
                if (CheckConfigurationFileExists())
                    config = CheckConfigurationFileCanBeRead();

            if (config != null)
            {
                CheckProviders(config);
                try
                {
                    FlexWikiWebApplication application = new FlexWikiWebApplication(FederationNamespaceMap, 
                        new LinkMaker("http://dummy"), OutputFormat.Testing);
                    Federation aFed = new Federation(application);
                    ValidateDefaultNamespace(aFed);
                    ValidateWritableNamespaces(aFed);
                }
                catch (Exception e)
                {
                    Result r = new Result("Error loading federation", Level.Error);
                    r.Writer.WritePara("Error loading federation: " + HtmlWriter.Escape(e.Message));
                    AddResult(r);
                }
            }
        }
        private void EstablishFederation()
        {
            if (Federation != null)
            {
                return;
            }

            FlexWikiWebApplication application = new FlexWikiWebApplication(new LinkMaker(PageUtilities.RootUrl));
            Federation = new Federation(application);
        }
        // Methods
        public void Check()
        {
            _results.Clear();
            FlexWikiWebApplication application = null;
            try
            {
                application = new FlexWikiWebApplication(
                    new LinkMaker("http://dummy"));
            }
            catch (Exception e)
            {
                Result r = new Result("Error initializing the application", Level.Error);
                r.Writer.WritePara("The error was: " + HtmlWriter.Escape(e.Message));
                AddResult(r);
            }

            if (application == null)
            {
                return;
            }

            FederationConfiguration config = application.FederationConfiguration;

            CheckPluginTypes();

            if (config != null)
            {
                CheckProviders(config);
                try
                {
                    Federation aFed = new Federation(application);
                    ValidateDefaultNamespace(aFed);
                    ValidateWritableNamespaces(aFed);
                }
                catch (Exception e)
                {
                    Result r = new Result("Error loading federation", Level.Error);
                    r.Writer.WritePara("Error loading federation: " + HtmlWriter.Escape(e.Message));
                    AddResult(r);
                }
            }
        }
        //////////
        ///Make sure we can read the configuration file in
        ///
        private void CheckPluginTypes()
        {
            FlexWikiWebApplication application = new FlexWikiWebApplication(new LinkMaker(""));
            FederationConfiguration configuration = application.FederationConfiguration;
            if (configuration == null)
                return;

            foreach (string plugin in configuration.Plugins)
            {
                Assembly assembly = null;
                string assemblyError = null;
                try
                {
                    assembly = Assembly.Load(plugin);
                }
                catch (FileNotFoundException)
                {
                    assemblyError = "Assembly not found.";
                }
                catch (BadImageFormatException)
                {
                    assemblyError = "Assembly is not a valid managed assembly.";
                }
                if (assemblyError == null)
                {
                    Result r = new Result("Plugin found and loaded successfully", Level.OK);
                    r.Writer.Write(@"<p>The plugin <b>" + HtmlWriter.Escape(plugin) + "</b> has been successfully loaded.</p>");
                    AddResult(r);
                }
                else
                {
                    Result r = new Result("Plugin not found", Level.Error);
                    r.Writer.Write(@"<p>The plugin <b>" + HtmlWriter.Escape(plugin) + "</b> could not be loaded.</p>");
                    r.Writer.Write(@"<p>" + HtmlWriter.Escape(assemblyError) + "</p>");
                    AddResult(r);
                }
            }
        }
Example #6
0
        public static string InsertStylesheetReferences(Federation federation, FlexWikiWebApplication wikiApplication)
        {
            string answer = MainStylesheetReference();
            QualifiedTopicRevision revision = GetTopicRevision(federation);
            string styleSheet = null;
            if (revision.IsQualified)
            {
                try
                {
                    styleSheet = federation.GetTopicPropertyValue(revision, "Stylesheet");
                }
                catch (FlexWikiAuthorizationException)
                {
                    // We don't want to blow up just because we can't read the topic. Continue as
                    // if there was no stylesheet
                }
            }

            if (!string.IsNullOrEmpty(styleSheet))
            {
                answer += GetStylesheetLink(styleSheet, DefaultStylesheet, false);
            }
            else
            {
                string styleOverride = wikiApplication.ApplicationConfiguration.OverrideStylesheet;
                if (styleOverride != null && styleOverride.Length > 0)
                {
                    answer += GetStylesheetLink(styleOverride, DefaultStylesheet, false);
                }
            }

            foreach(AlternateStylesheetConfiguration altStyle in wikiApplication.ApplicationConfiguration.AlternateStylesheets)
            {
                answer += GetStylesheetLink(altStyle.Href, altStyle.Title, true);
            }
            return answer;
        }
Example #7
0
 public static string InsertFavicon(FlexWikiWebApplication wikiApplication)
 {
     string answer = "\n<link rel=\"shortcut icon\" href=\"{0}{1}\" />";
     string faviconFilePath = HttpContext.Current.Server.MapPath("favicon.ico");
     if (!wikiApplication.ApplicationConfiguration.DisableFavicon)
     {
         try
         {
             if (File.Exists(faviconFilePath))
             {
                 answer = string.Format(answer, RootUrl, "favicon.ico");
                 return answer;
             }
             else
             {
                 return "";
             }
         }
         catch
         {
             return "";
         }
     }
     else
     {
         return "";
     }
 }
Example #8
0
        private void EstablishFederation()
        {
            if (Federation != null)
            {
                // If we have one, just make sure it's valid
                /*
                 * Federation.Validate();
                 * return;
                 */
                throw new NotImplementedException("Do we need the validate call? What bad thing happens if it's gone?");
            }

            // nope - need a new one
            string federationNamespaceMap = FederationNamespaceMapPath;
            if (federationNamespaceMap == null)
            {
                throw new Exception("No namespace map file defined.  Please set the FederationNamespaceMapFile key in <appSettings> in web.config to point to a namespace map file.");
            }
            string fsPath = MapPath(federationNamespaceMap);
            FlexWikiWebApplication application = new FlexWikiWebApplication(
                fsPath, TheLinkMaker);
            Federation fed = new Federation(application);
            SetFederation(fed);

            // Setup event monitoring
            SetupUpdateMonitoring();
        }
Example #9
0
        //////////
        ///Make sure we can read the configuration file in
        ///
        private FederationConfiguration CheckConfigurationFileCanBeRead()
        {
            FederationConfiguration config = null;
            try
            {
                FlexWikiWebApplication application = new FlexWikiWebApplication(FederationNamespaceMap, null);
                config = application.FederationConfiguration; 
            }
            catch (Exception ex)
            {
                Result r = new Result("Missing configuration file", Level.Error);
                r.Writer.Write(@"<p>You specified a federation configuration file, but an error occurred while reading it.  The federation
configuration file is stored here: <b>" + HtmlWriter.Escape(FederationNamespaceMap) + @"</b> and and the following error occurred while reading the file:");
                r.Writer.Write("<p><blockquote>" + HtmlWriter.Escape(ex.ToString()) + "</blockquote>");
                r.Writer.Write(@"<p>Here is an example of a valid federation configuration file:");
                r.Writer.Write(ExampleConfig());
                AddResult(r);
                return null;
            }
            OK("Federation configuration file successfully read");
            return config;
        }