/// <summary>
        /// Builds the project URL.	
        /// </summary>
        /// <param name="action">The action.</param>
        /// <param name="projectSpecifier">The project specifier.</param>
        /// <returns></returns>
        /// <remarks></remarks>
		public string BuildProjectUrl(string action, IProjectSpecifier projectSpecifier)
		{
			return urlBuilder.BuildUrl(
				action, 
				string.Empty,
				GeneratePath(projectSpecifier.ServerSpecifier.ServerName, projectSpecifier.ProjectName, string.Empty));
		}
        public bool ForceBuild(IProjectSpecifier projectSpecifier)
        {
            bool clientInfoRequired = false;
            ArrayList clientInfoList = new ArrayList();
            ICruiseManager manager = GetCruiseManager(projectSpecifier.ServerSpecifier);
            IForceFilter[] forceFilters = this.GetProject(manager, projectSpecifier.ProjectName).ForceFilters;

            if (forceFilters != null && forceFilters.Length != 0)
            {
                foreach (IForceFilter forceFilter in forceFilters)
                {
                    if (forceFilter.RequiresClientInformation)
                    {
                        clientInfoRequired = true;
                        ForceFilterClientInfo info = forceFilter.GetClientInfo();
                        clientInfoList.Add(info);
                    }
                }
            }
            if (clientInfoRequired)
            {
                ForceFilterClientInfo[] clientInfo;
                clientInfo = (ForceFilterClientInfo[]) clientInfoList.ToArray(typeof(ForceFilterClientInfo));
                return manager.ForceBuild(projectSpecifier.ProjectName, clientInfo);
            }
            else
            {
                return manager.ForceBuild(projectSpecifier.ProjectName);
            }
        }
예제 #3
0
		public ProjectLink(ICruiseUrlBuilder urlBuilder, IProjectSpecifier projectSpecifier, string text, string action)
			: base (text)
		{
			this.urlBuilder = urlBuilder;
			this.action = action;
			this.buildSpecifier = projectSpecifier;
		}
		public void Setup()
		{
			urlBuilderMock = new DynamicMock(typeof (IUrlBuilder));
			serverSpecifier = new DefaultServerSpecifier("myserver");
			projectSpecifier = new DefaultProjectSpecifier(serverSpecifier, "myproject");
			buildSpecifier = new DefaultBuildSpecifier(projectSpecifier, "mybuild");
			cruiseUrlBuilder = new DefaultCruiseUrlBuilder((IUrlBuilder) urlBuilderMock.MockInstance);
		}
 /// <summary>
 /// Checks the security permissions for a user for a project.
 /// </summary>
 /// <param name="projectSpecifier">The project to check.</param>
 /// <param name="userName">The name of the user.</param>
 /// <param name="sessionToken"></param>
 /// <returns>A set of diagnostics information.</returns>
 public virtual List<SecurityCheckDiagnostics> DiagnoseSecurityPermissions(IProjectSpecifier projectSpecifier, string sessionToken, string userName)
 {
     var response = GetCruiseManager(projectSpecifier, sessionToken)
         .DiagnoseSecurityPermissions(userName, new string[] {
             projectSpecifier.ProjectName
         });
     return response;
 }
 public IAbsoluteLink[] GetProjectPluginLinks(IProjectSpecifier projectSpecifier)
 {
     ArrayList links = new ArrayList();
     foreach (IPlugin plugin in pluginConfiguration.ProjectPlugins)
     {
         links.Add(LinkFactory.CreateProjectLink(projectSpecifier, plugin.LinkDescription, plugin.NamedActions[0].ActionName));
     }
     return (IAbsoluteLink[]) links.ToArray(typeof (IAbsoluteLink));
 }
		private IBuildSpecifier[] CreateBuildSpecifiers(IProjectSpecifier projectSpecifier, string[] buildNames)
		{
			var buildSpecifiers = new List<IBuildSpecifier>();
			foreach (string buildName in buildNames)
			{
				buildSpecifiers.Add(new DefaultBuildSpecifier(projectSpecifier, buildName));
			}
			return buildSpecifiers.ToArray();
		}
예제 #8
0
 public DeleteProjectModel(IProjectSpecifier projectSpecifier, string message, bool allowDelete,
     bool purgeWorkingDirectory, bool purgeArtifactDirectory, bool purgeSourceControlEnvironment)
 {
     this.message = message;
     this.allowDelete = allowDelete;
     this.purgeSourceControlEnvironment = purgeSourceControlEnvironment;
     this.purgeArtifactDirectory = purgeArtifactDirectory;
     this.purgeWorkingDirectory = purgeWorkingDirectory;
     this.projectSpecifier = projectSpecifier;
 }
예제 #9
0
        public HtmlFragmentResponse GenerateAllBuildsView(IProjectSpecifier projectSpecifier, string sessionToken)
        {
            Hashtable primaryContext = new Hashtable();
            Hashtable secondaryContext = new Hashtable();

            secondaryContext["links"] = linkListFactory.CreateStyledBuildLinkList(farmService.GetBuildSpecifiers(projectSpecifier, sessionToken), BuildReportBuildPlugin.ACTION_NAME);
            primaryContext["buildRows"] = velocityTransformer.Transform(@"BuildRows.vm", secondaryContext);
            primaryContext["allBuildsLink"] = linkFactory.CreateProjectLink(projectSpecifier, string.Empty, ViewAllBuildsProjectPlugin.ACTION_NAME);

            return velocityViewGenerator.GenerateView(@"AllBuilds.vm", primaryContext);
        }
		public void ShouldUrlEncodeProject()
		{
			// Setup
			urlBuilderMock.ExpectAndReturn("BuildUrl", "myUrl", "myAction", "", "server/myserver/project/myproject%232");
			projectSpecifier = new DefaultProjectSpecifier(serverSpecifier, "myproject#2");

			// Execute
			string url = cruiseUrlBuilder.BuildProjectUrl("myAction", projectSpecifier);

			// Verify
			Assert.AreEqual("myUrl", url);
			VerifyAll();
		}
		public void Setup()
		{
            urlBuilderMock = mocks.DynamicMock<ICruiseUrlBuilder>();
            SetupResult.For(urlBuilderMock.BuildProjectUrl(null, null))
                .IgnoreArguments()
                .Return("myLinkUrl");
			linkFactoryMock = new DynamicMock(typeof(ILinkFactory));
			projectGrid = new ProjectGrid();

			serverSpecifier = new DefaultServerSpecifier("server");
			projectSpecifier = new DefaultProjectSpecifier(serverSpecifier, "my project");

			projectLink = new GeneralAbsoluteLink("myLinkText", "myLinkUrl");
		}
        public bool IsDisplayedForProject(IProjectSpecifier project)
        {
            string projectName = project.ProjectName;

            if (includedProjects.Count > 0)
            {
                return(includedProjects.Contains(project.ProjectName));
            }
            else if (excludedProjects.Count > 0)
            {
                return(!excludedProjects.Contains(projectName));
            }
            else
            {
                return(true);
            }
        }
        public bool IsDisplayedForProject(IProjectSpecifier project)
        {
            string projectName = project.ProjectName;

            if (includedProjects.Count > 0)
            {
                return includedProjects.Contains(project.ProjectName);
            }
            else if (excludedProjects.Count > 0)
            {
                return !excludedProjects.Contains(projectName);
            }
            else
            {
                return true;
            }
        }
예제 #14
0
 public DefaultBuildSpecifier(IProjectSpecifier projectSpecifier, string buildName)
 {
     if (projectSpecifier == null)
     {
         throw new CruiseControlException("Build Specifier cannot be instantiated with a null Project Specifier");
     }
     if (buildName == null)
     {
         throw new CruiseControlException("Build Specifier cannot be instantiated with a null build name");
     }
     if (buildName == string.Empty)
     {
         throw new CruiseControlException("Build Specifier cannot be instantiated with an empty build name");
     }
     this.projectSpecifier = projectSpecifier;
     this.buildName = buildName;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultBuildSpecifier" /> class.
 /// </summary>
 /// <param name="projectSpecifier">The project specifier.</param>
 /// <param name="buildName">Name of the build.</param>
 /// <remarks></remarks>
 public DefaultBuildSpecifier(IProjectSpecifier projectSpecifier, string buildName)
 {
     if (projectSpecifier == null)
     {
         throw new CruiseControlException("Build Specifier cannot be instantiated with a null Project Specifier");
     }
     if (buildName == null)
     {
         throw new CruiseControlException("Build Specifier cannot be instantiated with a null build name");
     }
     if ((buildName != null && buildName.Length == 0))
     {
         throw new CruiseControlException("Build Specifier cannot be instantiated with an empty build name");
     }
     this.projectSpecifier = projectSpecifier;
     this.buildName        = buildName;
 }
예제 #16
0
        public IResponse Execute(ICruiseRequest cruiseRequest)
        {
            Hashtable         velocityContext  = new Hashtable();
            IProjectSpecifier projectSpecifier = cruiseRequest.ProjectSpecifier;

            IBuildSpecifier[] buildSpecifiers = farmService.GetMostRecentBuildSpecifiers(projectSpecifier, 1);
            if (buildSpecifiers.Length == 1)
            {
                velocityContext["mostRecentBuildUrl"] = linkFactory.CreateProjectLink(projectSpecifier, LatestBuildReportProjectPlugin.ACTION_NAME).Url;
            }

            velocityContext["projectName"]     = projectSpecifier.ProjectName;
            velocityContext["externalLinks"]   = farmService.GetExternalLinks(projectSpecifier);
            velocityContext["noLogsAvailable"] = (buildSpecifiers.Length == 0);

            return(viewGenerator.GenerateView(@"ProjectReport.vm", velocityContext));
        }
예제 #17
0
        public HtmlFragmentResponse Execute()
        {
            Hashtable velocityContext      = new Hashtable();
            string    velocityTemplateName = "";

            string serverName = request.ServerName;

            if (serverName == "")
            {
                velocityContext["links"] = pluginLinkCalculator.GetFarmPluginLinks();
                velocityTemplateName     = @"FarmSideBar.vm";
            }
            else
            {
                string projectName = request.ProjectName;
                if (projectName == "")
                {
                    velocityContext["links"] = pluginLinkCalculator.GetServerPluginLinks(request.ServerSpecifier);
                    velocityTemplateName     = @"ServerSideBar.vm";
                }
                else
                {
                    string buildName = request.BuildName;
                    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);
                        velocityContext["previousLink"]      = linkFactory.CreateBuildLink(buildNameRetriever.GetPreviousBuildSpecifier(buildSpecifier), "", BuildReportBuildPlugin.ACTION_NAME);
                        velocityTemplateName = @"BuildSideBar.vm";
                    }
                }
            }

            return(velocityViewGenerator.GenerateView(velocityTemplateName, velocityContext) as HtmlFragmentResponse);
        }
        public HtmlFragmentResponse GenerateAllBranchesView(IProjectSpecifier projectSpecifier, string sessionToken, string currentBranch, string[] branches)
        {
            string color = currentBranch == "Sourcecontrol not found" ? "#ff0000" : "#2E8A2E";
            string html  = "<form method=\"POST\">";

            html += string.Format("<h2>Current branch - <font color=\"{1}\">{0}</font></h2>", currentBranch, color);
            if (branches != null)
            {
                html += GetSelect(branches);
                html += "<button>Change</button>";
            }
            else
            {
                html += "<h2><font color=\"#ff0000\">Sorry, I can't get branches.</font></h2>";
            }
            html += "</form>";
            return(new HtmlFragmentResponse(html));
        }
예제 #19
0
        public static GeneralAbsoluteLink CreateRSSLink(ILinkFactory linkFactory, IProjectSpecifier projectSpecifier)
        {
            string MachineName;

            if (System.Web.HttpContext.Current == null ) 
            {
                MachineName = "localhost";
            }
            else
            {
                MachineName = System.Web.HttpContext.Current.Request.Url.Host;
                if (!System.Web.HttpContext.Current.Request.Url.IsDefaultPort)
                    MachineName = MachineName + ":" + System.Web.HttpContext.Current.Request.Url.Port;
            }

            return  new GeneralAbsoluteLink("RSS",string.Format(System.Globalization.CultureInfo.CurrentCulture,"http://{0}{1}",
                         MachineName,  
                         linkFactory.CreateProjectLink(projectSpecifier, WebDashboard.Plugins.RSS.RSSFeed.ACTION_NAME).Url));
       }
예제 #20
0
        // ToDo - use concatenatable views here, not strings
        // ToDo - something better for errors
        public string BuildRecentBuildsTable(IProjectSpecifier projectSpecifier)
        {
            Hashtable primaryContext = new Hashtable();
            Hashtable secondaryContext = new Hashtable();

            try
            {
                secondaryContext["links"] = linkListFactory.CreateStyledBuildLinkList(farmService.GetMostRecentBuildSpecifiers(projectSpecifier, 10), BuildReportBuildPlugin.ACTION_NAME);
                primaryContext["buildRows"] = velocityTransformer.Transform(@"BuildRows.vm", secondaryContext);
                primaryContext["allBuildsLink"] = linkFactory.CreateProjectLink(projectSpecifier, "", ViewAllBuildsProjectPlugin.ACTION_NAME);

                return velocityTransformer.Transform(@"RecentBuilds.vm", primaryContext);
            }
            catch (Exception)
            {
                // Assume exception also caught where we care about (i.e. by action)
                return "";
            }
        }
예제 #21
0
        // ToDo - use concatenatable views here, not strings
        // ToDo - something better for errors
        public string BuildRecentBuildsTable(IProjectSpecifier projectSpecifier)
        {
            Hashtable primaryContext   = new Hashtable();
            Hashtable secondaryContext = new Hashtable();

            try
            {
                secondaryContext["links"]       = linkListFactory.CreateStyledBuildLinkList(farmService.GetMostRecentBuildSpecifiers(projectSpecifier, 10), BuildReportBuildPlugin.ACTION_NAME);
                primaryContext["buildRows"]     = velocityTransformer.Transform(@"BuildRows.vm", secondaryContext);
                primaryContext["allBuildsLink"] = linkFactory.CreateProjectLink(projectSpecifier, "", ViewAllBuildsProjectPlugin.ACTION_NAME);

                return(velocityTransformer.Transform(@"RecentBuilds.vm", primaryContext));
            }
            catch (Exception)
            {
                // Assume exception also caught where we care about (i.e. by action)
                return("");
            }
        }
        public static GeneralAbsoluteLink CreateRSSLink(ILinkFactory linkFactory, IProjectSpecifier projectSpecifier)
        {
            string MachineName;

            if (System.Web.HttpContext.Current == null)
            {
                MachineName = "localhost";
            }
            else
            {
                MachineName = System.Web.HttpContext.Current.Request.Url.Host;
                if (!System.Web.HttpContext.Current.Request.Url.IsDefaultPort)
                {
                    MachineName = MachineName + ":" + System.Web.HttpContext.Current.Request.Url.Port;
                }
            }

            return(new GeneralAbsoluteLink("RSS", string.Format(System.Globalization.CultureInfo.CurrentCulture, "http://{0}{1}",
                                                                MachineName,
                                                                linkFactory.CreateProjectLink(projectSpecifier, WebDashboard.Plugins.RSS.RSSFeed.ACTION_NAME).Url)));
        }
        public void Setup()
        {
            serverSpecifier   = new DefaultServerSpecifier(serverName);
            projectSpecifier  = new DefaultProjectSpecifier(serverSpecifier, projectName);
            buildSpecifier    = new DefaultBuildSpecifier(projectSpecifier, buildName);
            linkFactoryMock   = new Mock <ILinkFactory>();
            configurationMock = new Mock <IPluginConfiguration>();
            Plugins           = new DefaultPluginLinkCalculator((ILinkFactory)linkFactoryMock.Object, (IPluginConfiguration)configurationMock.Object);

            pluginMock1 = new Mock <IPlugin>();
            pluginMock2 = new Mock <IPlugin>();
            action1     = new ImmutableNamedAction("Action Name 1", null);
            action2     = new ImmutableNamedAction("Action Name 2", null);
            action3     = new ImmutableNamedAction("Action Name 3", null);
            pluginMock1.SetupGet(plugin => plugin.LinkDescription).Returns("Description 1").Verifiable();
            pluginMock1.SetupGet(plugin => plugin.NamedActions).Returns(new INamedAction[] { action1 }).Verifiable();
            pluginMock2.SetupGet(plugin => plugin.LinkDescription).Returns("Description 2").Verifiable();
            pluginMock2.SetupGet(plugin => plugin.NamedActions).Returns(new INamedAction[] { action2 }).Verifiable();
            link1 = (IAbsoluteLink) new Mock <IAbsoluteLink>().Object;
            link2 = (IAbsoluteLink) new Mock <IAbsoluteLink>().Object;
        }
예제 #24
0
        public void Setup()
        {
            serverSpecifier   = new DefaultServerSpecifier(serverName);
            projectSpecifier  = new DefaultProjectSpecifier(serverSpecifier, projectName);
            buildSpecifier    = new DefaultBuildSpecifier(projectSpecifier, buildName);
            linkFactoryMock   = new DynamicMock(typeof(ILinkFactory));
            configurationMock = new DynamicMock(typeof(IPluginConfiguration));
            Plugins           = new DefaultPluginLinkCalculator((ILinkFactory)linkFactoryMock.MockInstance, (IPluginConfiguration)configurationMock.MockInstance);

            pluginMock1 = new DynamicMock(typeof(IPlugin));
            pluginMock2 = new DynamicMock(typeof(IPlugin));
            action1     = new ImmutableNamedAction("Action Name 1", null);
            action2     = new ImmutableNamedAction("Action Name 2", null);
            action3     = new ImmutableNamedAction("Action Name 3", null);
            pluginMock1.ExpectAndReturn("LinkDescription", "Description 1");
            pluginMock1.ExpectAndReturn("NamedActions", new INamedAction[] { action1 });
            pluginMock2.ExpectAndReturn("LinkDescription", "Description 2");
            pluginMock2.ExpectAndReturn("NamedActions", new INamedAction[] { action2 });
            link1 = (IAbsoluteLink) new DynamicMock(typeof(IAbsoluteLink)).MockInstance;
            link2 = (IAbsoluteLink) new DynamicMock(typeof(IAbsoluteLink)).MockInstance;
        }
		public void Setup()
		{
			serverSpecifier = new DefaultServerSpecifier(serverName);
			projectSpecifier = new DefaultProjectSpecifier(serverSpecifier, projectName);
			buildSpecifier = new DefaultBuildSpecifier(projectSpecifier, buildName);
			linkFactoryMock = new DynamicMock(typeof (ILinkFactory));
			configurationMock = new DynamicMock(typeof (IPluginConfiguration));
			Plugins = new DefaultPluginLinkCalculator((ILinkFactory) linkFactoryMock.MockInstance, (IPluginConfiguration) configurationMock.MockInstance);

			pluginMock1 = new DynamicMock(typeof (IPlugin));
			pluginMock2 = new DynamicMock(typeof (IPlugin));
			action1 = new ImmutableNamedAction("Action Name 1", null);
			action2 = new ImmutableNamedAction("Action Name 2", null);
			action3 = new ImmutableNamedAction("Action Name 3", null);
			pluginMock1.ExpectAndReturn("LinkDescription", "Description 1");
			pluginMock1.ExpectAndReturn("NamedActions", new INamedAction[] {action1});
			pluginMock2.ExpectAndReturn("LinkDescription", "Description 2");
			pluginMock2.ExpectAndReturn("NamedActions", new INamedAction[] {action2});
			link1 = (IAbsoluteLink) new DynamicMock(typeof (IAbsoluteLink)).MockInstance;
			link2 = (IAbsoluteLink) new DynamicMock(typeof (IAbsoluteLink)).MockInstance;
		}
        public bool ForceBuild(IProjectSpecifier projectSpecifier)
        {
            bool           clientInfoRequired = false;
            ArrayList      clientInfoList     = new ArrayList();
            ICruiseManager manager            = GetCruiseManager(projectSpecifier.ServerSpecifier);

            IForceFilter[] forceFilters = this.GetProject(manager, projectSpecifier.ProjectName).ForceFilters;

            if (forceFilters != null && forceFilters.Length != 0)
            {
                foreach (IForceFilter forceFilter in forceFilters)
                {
                    if (forceFilter.RequiresClientInformation)
                    {
                        clientInfoRequired = true;
                        ForceFilterClientInfo info = forceFilter.GetClientInfo();
                        clientInfoList.Add(info);
                    }
                }
            }

            Dictionary <string, string> webParams = new Dictionary <string, string>();

            foreach (String key in HttpContext.Current.Request.Form.Keys)
            {
                String value = HttpContext.Current.Request.Params[key];
                webParams.Add(key, value);
            }

            if (clientInfoRequired)
            {
                ForceFilterClientInfo[] clientInfo;
                clientInfo = (ForceFilterClientInfo[])clientInfoList.ToArray(typeof(ForceFilterClientInfo));
                return(manager.ForceBuild(projectSpecifier.ProjectName, webParams, clientInfo));
            }
            else
            {
                return(manager.ForceBuild(projectSpecifier.ProjectName, webParams));
            }
        }
예제 #27
0
        private string ForceBuildIfNecessary(IProjectSpecifier projectSpecifier, IRequest request, string sessionToken)
        {
            // Retrieve the parameters
            var parameters = new Dictionary <string, string>();

            foreach (string parameterName in HttpContext.Current.Request.Form.AllKeys)
            {
                if (parameterName.StartsWith("param_"))
                {
                    parameters.Add(parameterName.Substring(6), HttpContext.Current.Request.Form[parameterName]);
                }
            }

            if (!string.IsNullOrEmpty(request.FindParameterStartingWith("StopBuild")))
            {
                farmService.Stop(projectSpecifier, sessionToken);
                return(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Stopping project {0}", projectSpecifier.ProjectName));
            }
            else if (!string.IsNullOrEmpty(request.FindParameterStartingWith("StartBuild")))
            {
                farmService.Start(projectSpecifier, sessionToken);
                return(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Starting project {0}", projectSpecifier.ProjectName));
            }
            else if (!string.IsNullOrEmpty(request.FindParameterStartingWith("ForceBuild")))
            {
                farmService.ForceBuild(projectSpecifier, sessionToken, parameters);
                return(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Build successfully forced for {0}", projectSpecifier.ProjectName));
            }
            else if (!string.IsNullOrEmpty(request.FindParameterStartingWith("AbortBuild")))
            {
                farmService.AbortBuild(projectSpecifier, sessionToken);
                return(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Abort successfully forced for {0}", projectSpecifier.ProjectName));
            }
            else
            {
                return(string.Empty);
            }
        }
        public void Setup()
        {
            configurationMock              = new Mock <IRemoteServicesConfiguration>();
            cruiseManagerFactoryMock       = new Mock <ICruiseServerClientFactory>();
            cruiseManagerMock              = new Mock <ICruiseServerClient>();
            serverSpecifier                = new DefaultServerSpecifier("myserver");
            projectSpecifier               = new DefaultProjectSpecifier(serverSpecifier, "myproject");
            buildSpecifier                 = new DefaultBuildSpecifier(projectSpecifier, "mybuild");
            buildSpecifierForUnknownServer = new DefaultBuildSpecifier(new DefaultProjectSpecifier(new DefaultServerSpecifier("unknownServer"), "myProject"), "myBuild");

            managerWrapper = new ServerAggregatingCruiseManagerWrapper(
                (IRemoteServicesConfiguration)configurationMock.Object,
                (ICruiseServerClientFactory)cruiseManagerFactoryMock.Object
                );

            serverLocation                 = new ServerLocation();
            serverLocation.Name            = "myserver";
            serverLocation.Url             = "http://myurl";
            serverLocation.AllowForceBuild = true;

            otherServerLocation      = new ServerLocation();
            otherServerLocation.Name = "myotherserver";
            otherServerLocation.Url  = "http://myotherurl";
        }
		public void Setup()
		{
			farmServiceMock = new DynamicMock(typeof(IFarmService));
			velocityTransformerMock = new DynamicMock(typeof(IVelocityTransformer));
			velocityViewGeneratorMock = new DynamicMock(typeof(IVelocityViewGenerator));
			linkFactoryMock = new DynamicMock(typeof(ILinkFactory));
			linkListFactoryMock = new DynamicMock(typeof(ILinkListFactory));
		    fingerprintFactoryMock = new DynamicMock(typeof (IFingerprintFactory));
            urlBuilderMock = new DynamicMock(typeof(ICruiseUrlBuilder));

			lister = new RecentBuildLister(
				(IFarmService) farmServiceMock.MockInstance,
				(IVelocityTransformer) velocityTransformerMock.MockInstance,
				(IVelocityViewGenerator) velocityViewGeneratorMock.MockInstance,
				(ILinkFactory) linkFactoryMock.MockInstance,
				(ILinkListFactory) linkListFactoryMock.MockInstance,
                (IFingerprintFactory) fingerprintFactoryMock.MockInstance,
                (ICruiseUrlBuilder)urlBuilderMock.MockInstance,
                null);

			projectSpecifier = new DefaultProjectSpecifier(new DefaultServerSpecifier("myServer"), "myProject");
            build2Specifier = new DefaultBuildSpecifier(projectSpecifier, "log20070401013456.xml");
			build1Specifier = new DefaultBuildSpecifier(projectSpecifier, "build1");
		}
예제 #30
0
        public void Setup()
        {
            farmServiceMock           = new Mock <IFarmService>();
            velocityTransformerMock   = new Mock <IVelocityTransformer>();
            velocityViewGeneratorMock = new Mock <IVelocityViewGenerator>();
            linkFactoryMock           = new Mock <ILinkFactory>();
            linkListFactoryMock       = new Mock <ILinkListFactory>();
            fingerprintFactoryMock    = new Mock <IFingerprintFactory>();
            urlBuilderMock            = new Mock <ICruiseUrlBuilder>();

            lister = new RecentBuildLister(
                (IFarmService)farmServiceMock.Object,
                (IVelocityTransformer)velocityTransformerMock.Object,
                (IVelocityViewGenerator)velocityViewGeneratorMock.Object,
                (ILinkFactory)linkFactoryMock.Object,
                (ILinkListFactory)linkListFactoryMock.Object,
                (IFingerprintFactory)fingerprintFactoryMock.Object,
                (ICruiseUrlBuilder)urlBuilderMock.Object,
                null);

            projectSpecifier = new DefaultProjectSpecifier(new DefaultServerSpecifier("myServer"), "myProject");
            build2Specifier  = new DefaultBuildSpecifier(projectSpecifier, "log20070401013456.xml");
            build1Specifier  = new DefaultBuildSpecifier(projectSpecifier, "build1");
        }
		public void Setup()
		{
			configurationMock = new DynamicMock(typeof (IRemoteServicesConfiguration));
            cruiseManagerFactoryMock = new DynamicMock(typeof(ICruiseServerClientFactory));
			cruiseManagerMock = new DynamicMock(typeof (ICruiseServerClient));
			serverSpecifier = new DefaultServerSpecifier("myserver");
			projectSpecifier = new DefaultProjectSpecifier(serverSpecifier, "myproject");
			buildSpecifier = new DefaultBuildSpecifier(projectSpecifier, "mybuild");
			buildSpecifierForUnknownServer = new DefaultBuildSpecifier(new DefaultProjectSpecifier(new DefaultServerSpecifier("unknownServer"), "myProject"), "myBuild");

			managerWrapper = new ServerAggregatingCruiseManagerWrapper(
				(IRemoteServicesConfiguration) configurationMock.MockInstance,
                (ICruiseServerClientFactory)cruiseManagerFactoryMock.MockInstance
				);

			serverLocation = new ServerLocation();
			serverLocation.Name = "myserver";
			serverLocation.Url = "http://myurl";
			serverLocation.AllowForceBuild = true;

			otherServerLocation = new ServerLocation();
			otherServerLocation.Name = "myotherserver";
			otherServerLocation.Url = "http://myotherurl";
		}
 public virtual RemotingFileTransfer RetrieveFileTransfer(IProjectSpecifier projectSpecifier, string fileName, string sessionToken)
 {
     var response = GetCruiseManager(projectSpecifier, sessionToken)
         .RetrieveFileTransfer(projectSpecifier.ProjectName, fileName);
     return response as RemotingFileTransfer;
 }
        public void ForceBuild(IProjectSpecifier projectSpecifier, string sessionToken)
        {
            ForceBuild(projectSpecifier, sessionToken, new Dictionary<string, string>());
		}
예제 #34
0
 public IBuildSpecifier[] GetMostRecentBuildSpecifiers(IProjectSpecifier projectSpecifier, int buildCount)
 {
     return(CreateBuildSpecifiers(projectSpecifier, GetCruiseManager(projectSpecifier).GetMostRecentBuildNames(projectSpecifier.ProjectName, buildCount)));
 }
예제 #35
0
 // ToDo - use concatenatable views here, not strings
 // ToDo - something better for errors
 public string BuildRecentBuildsTable(IProjectSpecifier projectSpecifier, string sessionToken)
 {
     return BuildRecentBuildsTable(projectSpecifier, null, sessionToken);
 }
 /// <summary>
 /// Lists the build parameters for a project.
 /// </summary>
 /// <param name="projectSpecifier">The project to check.</param>
 /// <param name="sessionToken"></param>
 /// <returns>The list of parameters (if any).</returns>
 public virtual List <ParameterBase> ListBuildParameters(IProjectSpecifier projectSpecifier, string sessionToken)
 {
     return(GetCruiseManager(projectSpecifier, sessionToken)
            .ListBuildParameters(projectSpecifier.ProjectName));
 }
 public void UpdateProject(IProjectSpecifier projectSpecifier, string serializedProject, string sessionToken)
 {
     GetCruiseManager(projectSpecifier, sessionToken)
     .UpdateProject(projectSpecifier.ProjectName, serializedProject);
 }
 public void AbortBuild(IProjectSpecifier projectSpecifier, string sessionToken)
 {
     GetCruiseManager(projectSpecifier, sessionToken).AbortBuild(projectSpecifier.ProjectName);
 }
 public void ForceBuild(IProjectSpecifier projectSpecifier, string sessionToken)
 {
     ForceBuild(projectSpecifier, sessionToken, new Dictionary <string, string>());
 }
 /// <summary>
 /// Lists the build parameters for a project.
 /// </summary>
 /// <param name="projectSpecifier">The project to check.</param>
 /// <param name="sessionToken"></param>
 /// <returns>The list of parameters (if any).</returns>
 public virtual List<ParameterBase> ListBuildParameters(IProjectSpecifier projectSpecifier, string sessionToken)
 {
     return GetCruiseManager(projectSpecifier, sessionToken)
         .ListBuildParameters(projectSpecifier.ProjectName);
 }
 public bool IsDisplayedForProject(IProjectSpecifier project)
 {
     return(true);
 }
        private CruiseServerClientBase GetCruiseManager(IProjectSpecifier projectSpecifier, string sessionToken)
		{
            return GetCruiseManager(projectSpecifier.ServerSpecifier, sessionToken);
		}
 public string GetRSSFeed(IProjectSpecifier projectSpecifier, string sessionToken)
 {
     var response = GetCruiseManager(projectSpecifier, sessionToken)
         .GetRSSFeed(projectSpecifier.ProjectName);
     return response;
 }
예제 #44
0
 private void SetupProjectLinkExpectation(IProjectSpecifier projectSpecifierForLink)
 {
     linkFactoryMock.SetupResult("CreateProjectLink", projectLink, typeof(IProjectSpecifier), typeof(string));
 }
예제 #45
0
 public void Setup()
 {
     projectSpecifier = new DefaultProjectSpecifier(new DefaultServerSpecifier(serverName), projectName);
     urlBuilderMock   = new Mock <ICruiseUrlBuilder>();
     projectLink      = new ProjectLink((ICruiseUrlBuilder)urlBuilderMock.Object, projectSpecifier, description, this.action);
 }
예제 #46
0
 public IBuildSpecifier GetLatestBuildSpecifier(IProjectSpecifier projectSpecifier)
 {
     return(new DefaultBuildSpecifier(projectSpecifier, GetCruiseManager(projectSpecifier.ServerSpecifier).GetLatestBuildName(projectSpecifier.ProjectName)));
 }
 /// <summary>
 /// List the available packages for a project.
 /// </summary>
 /// <param name="projectSpecifier"></param>
 /// <param name="sessionToken"></param>
 /// <returns></returns>
 public virtual PackageDetails[] RetrievePackageList(IProjectSpecifier projectSpecifier, string sessionToken)
 {
     var response = GetCruiseManager(projectSpecifier, sessionToken)
         .RetrievePackageList(projectSpecifier.ProjectName);
     return response.ToArray();
 }
 /// <summary>
 /// Takes a status snapshot of a project.
 /// </summary>
 /// <param name="projectSpecifier">The project.</param>
 /// <param name="sessionToken"></param>
 /// <returns>The snapshot of the current status.</returns>
 public ProjectStatusSnapshot TakeStatusSnapshot(IProjectSpecifier projectSpecifier, string sessionToken)
 {
     var response = GetCruiseManager(projectSpecifier, sessionToken)
         .TakeStatusSnapshot(projectSpecifier.ProjectName);
     return response;
 }
        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));
        }
 /// <summary>
 /// Retrieves the identifier for a project on a linked site.
 /// </summary>
 /// <param name="projectSpecifier">The project to retrieve the identifier for.</param>
 /// <param name="siteName">The name of the linked site.</param>
 /// <param name="sessionId"></param>
 /// <returns>The identifier of the other site.</returns>
 public string GetLinkedSiteId(IProjectSpecifier projectSpecifier, string sessionId, string siteName)
 {
     try
     {
         var response = GetCruiseManager(projectSpecifier, sessionId)
             .GetLinkedSiteId(projectSpecifier.ProjectName, siteName);
         return response;
     }
     catch (NotImplementedException)
     {
         return string.Empty;
     }
 }
        public void ForceBuild(IProjectSpecifier projectSpecifier, string sessionToken, Dictionary <string, string> parameters)
        {
            var manager = GetCruiseManager(projectSpecifier, sessionToken);

            manager.ForceBuild(projectSpecifier.ProjectName, NameValuePair.FromDictionary(parameters));
        }
        public IBuildSpecifier[] GetBuildSpecifiers(IProjectSpecifier projectSpecifier, string sessionToken)
		{
            var response = GetCruiseManager(projectSpecifier.ServerSpecifier, sessionToken)
                .GetBuildNames(projectSpecifier.ProjectName);
            return CreateBuildSpecifiers(projectSpecifier, response);
		}
 public void Stop(IProjectSpecifier projectSpecifier, string sessionToken)
 {
     GetCruiseManager(projectSpecifier.ServerSpecifier, sessionToken)
     .StopProject(projectSpecifier.ProjectName);
 }
        public IBuildSpecifier[] GetMostRecentBuildSpecifiers(IProjectSpecifier projectSpecifier, int buildCount, string sessionToken)
		{
            var response = GetCruiseManager(projectSpecifier, sessionToken)
                .GetMostRecentBuildNames(projectSpecifier.ProjectName, buildCount);
            return CreateBuildSpecifiers(projectSpecifier, response);
		}
 private CruiseServerClientBase GetCruiseManager(IProjectSpecifier projectSpecifier, string sessionToken)
 {
     return(GetCruiseManager(projectSpecifier.ServerSpecifier, sessionToken));
 }
예제 #56
0
 private ICruiseManager GetCruiseManager(IProjectSpecifier projectSpecifier)
 {
     return(GetCruiseManager(projectSpecifier.ServerSpecifier));
 }
 public void DeleteProject(IProjectSpecifier projectSpecifier, bool purgeWorkingDirectory, bool purgeArtifactDirectory, bool purgeSourceControlEnvironment, string sessionToken)
 {
     GetCruiseManager(projectSpecifier, sessionToken)
     .DeleteProject(projectSpecifier.ProjectName, purgeWorkingDirectory, purgeArtifactDirectory, purgeSourceControlEnvironment);
 }
        public void DeleteProject(IProjectSpecifier projectSpecifier, bool purgeWorkingDirectory, bool purgeArtifactDirectory, bool purgeSourceControlEnvironment, string sessionToken)
		{
            GetCruiseManager(projectSpecifier, sessionToken)
                .DeleteProject(projectSpecifier.ProjectName, purgeWorkingDirectory, purgeArtifactDirectory, purgeSourceControlEnvironment);
		}
예제 #59
0
 public IAbsoluteLink CreateProjectLink(IProjectSpecifier projectSpecifier, string action)
 {
     return(new ProjectLink(cruiseUrlBuilder, projectSpecifier, projectSpecifier.ProjectName, action));
 }
예제 #60
0
 public IBuildSpecifier[] GetBuildSpecifiers(IProjectSpecifier projectSpecifier)
 {
     return(CreateBuildSpecifiers(projectSpecifier, GetCruiseManager(projectSpecifier).GetBuildNames(projectSpecifier.ProjectName)));
 }