public HtmlFragmentResponse Execute()
        {
            Hashtable velocityContext      = new Hashtable();
            string    velocityTemplateName = "";

            string serverName  = request.ServerName;
            string projectName = request.ProjectName;
            string buildName   = request.BuildName;

            velocityContext["serverName"]  = serverName;
            velocityContext["projectName"] = projectName;
            velocityContext["buildName"]   = buildName;

            if (serverName == "")
            {
                velocityContext["links"] = pluginLinkCalculator.GetFarmPluginLinks();
                velocityTemplateName     = @"FarmSideBar.vm";
            }
            else
            {
                if (projectName == "")
                {
                    velocityContext["links"] = pluginLinkCalculator.GetServerPluginLinks(request.ServerSpecifier);
                    velocityTemplateName     = @"ServerSideBar.vm";
                }
                else
                {
                    if (buildName == "")
                    {
                        IProjectSpecifier projectSpecifier = request.ProjectSpecifier;
                        velocityContext["links"]             = pluginLinkCalculator.GetProjectPluginLinks(projectSpecifier);
                        velocityContext["recentBuildsTable"] = recentBuildsViewBuilder.BuildRecentBuildsTable(projectSpecifier);
                        velocityTemplateName = @"ProjectSideBar.vm";
                    }
                    else
                    {
                        IBuildSpecifier buildSpecifier = request.BuildSpecifier;
                        velocityContext["links"]             = pluginLinkCalculator.GetBuildPluginLinks(buildSpecifier);
                        velocityContext["recentBuildsTable"] = recentBuildsViewBuilder.BuildRecentBuildsTable(buildSpecifier.ProjectSpecifier);
                        velocityContext["latestLink"]        = linkFactory.CreateProjectLink(request.ProjectSpecifier, LatestBuildReportProjectPlugin.ACTION_NAME);
                        velocityContext["nextLink"]          = linkFactory.CreateBuildLink(buildNameRetriever.GetNextBuildSpecifier(buildSpecifier), "", BuildReportBuildPlugin.ACTION_NAME, null);
                        velocityContext["previousLink"]      = linkFactory.CreateBuildLink(buildNameRetriever.GetPreviousBuildSpecifier(buildSpecifier), "", BuildReportBuildPlugin.ACTION_NAME, null);
                        velocityTemplateName = @"BuildSideBar.vm";
                    }
                }
            }

            return(velocityViewGenerator.GenerateView(velocityTemplateName, velocityContext) as HtmlFragmentResponse);
        }
        public HtmlFragmentResponse Execute(ICruiseRequest request)
        {
            Hashtable velocityContext = new Hashtable();
            string    velocityTemplateName;

            string serverName = request.ServerName;

            if (serverName == string.Empty)
            {
                velocityContext["links"] = pluginLinkCalculator.GetFarmPluginLinks();

                IServerSpecifier[] serverspecifiers = farmService.GetServerSpecifiers();
                velocityContext["serverlinks"] = linkListFactory.CreateServerLinkList(serverspecifiers, "ViewServerReport");

                IAbsoluteLink[] categoryLinks = GetCategoryLinks(serverspecifiers, request);
                velocityContext["showCategories"] = (categoryLinks != null) ? true : false;
                velocityContext["categorylinks"]  = categoryLinks;
                velocityContext["farmLink"]       = linkFactory.CreateFarmLink("Dashboard", FarmReportFarmPlugin.ACTION_NAME);
                velocityTemplateName = @"FarmSideBar.vm";
            }
            else
            {
                string projectName = request.ProjectName;
                if (projectName == string.Empty)
                {
                    IServerSpecifier serverSpecifier = request.ServerSpecifier;
                    velocityContext["links"]      = pluginLinkCalculator.GetServerPluginLinks(serverSpecifier);
                    velocityContext["serverlink"] = linkFactory.CreateServerLink(serverSpecifier, "ViewServerReport");

                    IAbsoluteLink[] categoryLinks = new IAbsoluteLink[0];
                    try
                    {
                        categoryLinks = GetCategoryLinks(serverSpecifier);
                    }
                    catch
                    {
                        // Ignore any error here - this is normally because the URL is incorrect, the error will be displayed in the main content
                    }

                    velocityContext["showCategories"] = (categoryLinks != null) ? true : false;
                    velocityContext["categorylinks"]  = categoryLinks;

                    velocityTemplateName = @"ServerSideBar.vm";
                }
                else
                {
                    string buildName = request.BuildName;
                    if (buildName == string.Empty)
                    {
                        IProjectSpecifier projectSpecifier = request.ProjectSpecifier;
                        velocityContext["links"]             = pluginLinkCalculator.GetProjectPluginLinks(projectSpecifier);
                        velocityContext["recentBuildsTable"] = recentBuildsViewBuilder.BuildRecentBuildsTable(projectSpecifier, request.RetrieveSessionToken());
                        velocityTemplateName = @"ProjectSideBar.vm";
                    }
                    else
                    {
                        IBuildSpecifier buildSpecifier = request.BuildSpecifier;
                        velocityContext["links"]             = pluginLinkCalculator.GetBuildPluginLinks(buildSpecifier);
                        velocityContext["recentBuildsTable"] = recentBuildsViewBuilder.BuildRecentBuildsTable(buildSpecifier, request.RetrieveSessionToken());
                        velocityContext["latestLink"]        = linkFactory.CreateProjectLink(request.ProjectSpecifier, LatestBuildReportProjectPlugin.ACTION_NAME);
                        velocityContext["nextLink"]          = linkFactory.CreateBuildLink(buildNameRetriever.GetNextBuildSpecifier(buildSpecifier, request.RetrieveSessionToken()), string.Empty, BuildReportBuildPlugin.ACTION_NAME);
                        velocityContext["previousLink"]      = linkFactory.CreateBuildLink(buildNameRetriever.GetPreviousBuildSpecifier(buildSpecifier, request.RetrieveSessionToken()), string.Empty, BuildReportBuildPlugin.ACTION_NAME);
                        velocityTemplateName = @"BuildSideBar.vm";
                    }
                }
            }

            return(velocityViewGenerator.GenerateView(velocityTemplateName, velocityContext));
        }