Esempio n. 1
0
        public ProjectGridRow[] GenerateProjectGridRows(ProjectStatusOnServer[] statusList, string forceBuildActionName,
                                                        ProjectGridSortColumn sortColumn, bool sortIsAscending)
        {
            ArrayList rows = new ArrayList();

            foreach (ProjectStatusOnServer statusOnServer in statusList)
            {
                ProjectStatus    status          = statusOnServer.ProjectStatus;
                IServerSpecifier serverSpecifier = statusOnServer.ServerSpecifier;
                string           projectName     = status.Name;
                rows.Add(
                    new ProjectGridRow(
                        projectName, statusOnServer.ServerSpecifier.ServerName, status.BuildStatus.ToString(),
                        CalculateHtmlColor(status.BuildStatus),
                        status.LastBuildDate,
                        (status.LastBuildLabel != null ? status.LastBuildLabel : "no build available"),
                        status.Status.ToString(),
                        status.Activity.ToString(),
                        urlBuilder.BuildFormName(forceBuildActionName),
                        linkFactory.CreateProjectLink(new DefaultProjectSpecifier(serverSpecifier, projectName), ProjectReportProjectPlugin.ACTION_NAME).Url
                        ));
            }

            rows.Sort(GetComparer(sortColumn, sortIsAscending));

            return((ProjectGridRow[])rows.ToArray(typeof(ProjectGridRow)));
        }
        /// <summary>
        /// Builds the server URL.	
        /// </summary>
        /// <param name="action">The action.</param>
        /// <param name="serverSpecifier">The server specifier.</param>
        /// <param name="queryString">The query string.</param>
        /// <returns></returns>
        /// <remarks></remarks>
		public string BuildServerUrl(string action, IServerSpecifier serverSpecifier, string queryString)
		{
			return urlBuilder.BuildUrl(
				action, 
				queryString, 
				GeneratePath(serverSpecifier.ServerName, string.Empty, string.Empty));
		}
Esempio n. 3
0
        public string GetServerVersion(IServerSpecifier serverSpecifier)
        {
            var response = GetCruiseManager(serverSpecifier, null)
                           .GetServerVersion();

            return(response);
        }
        /// <summary>
        /// Retrieve the amount of free disk space.
        /// </summary>
        /// <returns></returns>
        public virtual long GetFreeDiskSpace(IServerSpecifier serverSpecifier)
        {
            var response = GetCruiseManager(serverSpecifier, null)
                           .GetFreeDiskSpace();

            return(Convert.ToInt64(response));
        }
        /// <summary>
        /// Reads the specified number of filtered audit events.
        /// </summary>
        /// <param name="startPosition">The starting position.</param>
        /// <param name="numberOfRecords">The number of records to read.</param>
        /// <param name="filter">The filter to use.</param>
        /// <param name="serverSpecifier"></param>
        /// <param name="sessionToken"></param>
        /// <returns>A list of <see cref="AuditRecord"/>s containing the audit details that match the filter.</returns>
        public virtual List <AuditRecord> ReadAuditRecords(IServerSpecifier serverSpecifier, string sessionToken, int startPosition, int numberOfRecords, AuditFilterBase filter)
        {
            var response = GetCruiseManager(serverSpecifier, sessionToken)
                           .ReadAuditRecords(startPosition, numberOfRecords, filter);

            return(response);
        }
Esempio n. 6
0
        public IResponse Execute(string actionName, IServerSpecifier serverSpecifier, IRequest request)
        {
            Hashtable velocityContext = new Hashtable();

            velocityContext["forceBuildMessage"] = ForceBuildIfNecessary(request);
            return(GenerateView(farmService.GetProjectStatusListAndCaptureExceptions(serverSpecifier), velocityContext, actionName, request, serverSpecifier));
        }
        /// <summary>
        /// Lists all the users who have been defined on a server.
        /// </summary>
        /// <param name="serverSpecifier">The server to get the users from.</param>
        /// <param name="sessionToken"></param>
        /// <returns>
        /// A list of <see cref="UserDetails"/> containing the details on all the users
        /// who have been defined.
        /// </returns>
        public virtual List <UserDetails> ListAllUsers(IServerSpecifier serverSpecifier, string sessionToken)
        {
            var response = GetCruiseManager(serverSpecifier, sessionToken)
                           .ListUsers();

            return(response);
        }
Esempio n. 8
0
 public ServerLink(ICruiseUrlBuilder urlBuilder, IServerSpecifier serverSpecifier, string text, string action)
     : base(text)
 {
     this.urlBuilder = urlBuilder;
     this.action = action;
     this.serverSpecifier = serverSpecifier;
 }
Esempio n. 9
0
 /// <summary>
 /// Builds the server URL.
 /// </summary>
 /// <param name="action">The action.</param>
 /// <param name="serverSpecifier">The server specifier.</param>
 /// <param name="queryString">The query string.</param>
 /// <returns></returns>
 /// <remarks></remarks>
 public string BuildServerUrl(string action, IServerSpecifier serverSpecifier, string queryString)
 {
     return(urlBuilder.BuildUrl(
                action,
                queryString,
                GeneratePath(serverSpecifier.ServerName, string.Empty, string.Empty)));
 }
        public string GetServerVersion(IServerSpecifier serverSpecifier, string sessionToken)
        {
            var response = GetCruiseManager(serverSpecifier, sessionToken)
                           .GetServerVersion();

            return(response);
        }
Esempio n. 11
0
 public ServerLink(ICruiseUrlBuilder urlBuilder, IServerSpecifier serverSpecifier, string text, string action)
     : base(text)
 {
     this.urlBuilder      = urlBuilder;
     this.action          = action;
     this.serverSpecifier = serverSpecifier;
 }
Esempio n. 12
0
        public ProjectGridRow[] GenerateProjectGridRows(ProjectStatusOnServer[] statusList, string forceBuildActionName,
                                                        ProjectGridSortColumn sortColumn, bool sortIsAscending, string categoryFilter,
                                                        ICruiseUrlBuilder urlBuilder, Translations translations)
        {
            var rows = new List <ProjectGridRow>();

            foreach (ProjectStatusOnServer statusOnServer in statusList)
            {
                ProjectStatus           status           = statusOnServer.ProjectStatus;
                IServerSpecifier        serverSpecifier  = statusOnServer.ServerSpecifier;
                DefaultProjectSpecifier projectSpecifier = new DefaultProjectSpecifier(serverSpecifier, status.Name);

                if ((categoryFilter != string.Empty) && (categoryFilter != status.Category))
                {
                    continue;
                }

                rows.Add(
                    new ProjectGridRow(status,
                                       serverSpecifier,
                                       urlBuilder.BuildProjectUrl(ProjectReportProjectPlugin.ACTION_NAME, projectSpecifier),
                                       urlBuilder.BuildProjectUrl(ProjectParametersAction.ActionName, projectSpecifier),
                                       translations));
            }

            return(rows.OrderBy(a => a, GetComparer(sortColumn, sortIsAscending)).ToArray());
        }
        private IAbsoluteLink[] GetCategoryLinks(IServerSpecifier serverSpecifier)
        {
            if (serverSpecifier == null)
                return null;

            // create list of categories
            List<string> categories = new List<string>();

            foreach (ProjectStatusOnServer status in farmService
                .GetProjectStatusListAndCaptureExceptions(serverSpecifier, request.RetrieveSessionToken())
                .StatusAndServerList)
            {
                string category = status.ProjectStatus.Category;

                if (!string.IsNullOrEmpty(category) && !categories.Contains(category))
                    categories.Add(category);
            }

            // sort list if at least one element exists
            if (categories.Count == 0)
                return null;
            else
                categories.Sort();

            // use just created list to assemble wanted links
            List<GeneralAbsoluteLink> links = new List<GeneralAbsoluteLink>();
            string urlTemplate = linkFactory
                .CreateServerLink(serverSpecifier, "ViewServerReport")
                .Url + "?Category=";

            foreach (string category in categories)
                links.Add(new GeneralAbsoluteLink(category, urlTemplate + HttpUtility.UrlEncode(category)));

            return links.ToArray();
        }
Esempio n. 14
0
	    private static void WriteProjectStatus(XmlWriter xmlWriter, ProjectStatus status, IServerSpecifier serverSpecifier)
	    {
	        xmlWriter.WriteStartElement("Project");
	        xmlWriter.WriteAttributeString("name", status.Name);
	        xmlWriter.WriteAttributeString("category", status.Category);
	        xmlWriter.WriteAttributeString("activity", status.Activity.ToString());
	        xmlWriter.WriteAttributeString("lastBuildStatus", status.BuildStatus.ToString());
	        xmlWriter.WriteAttributeString("lastBuildLabel", status.LastSuccessfulBuildLabel);
	        xmlWriter.WriteAttributeString("lastBuildTime", XmlConvert.ToString(status.LastBuildDate, XmlDateTimeSerializationMode.Local));
	        xmlWriter.WriteAttributeString("nextBuildTime", XmlConvert.ToString(status.NextBuildTime, XmlDateTimeSerializationMode.Local));
	        xmlWriter.WriteAttributeString("webUrl", status.WebURL);
            xmlWriter.WriteAttributeString("CurrentMessage", status.CurrentMessage);
            xmlWriter.WriteAttributeString("BuildStage", status.BuildStage);
            xmlWriter.WriteAttributeString("serverName", serverSpecifier.ServerName);
            xmlWriter.WriteAttributeString("description", status.Description);

            xmlWriter.WriteStartElement("messages");

            foreach (Message m in status.Messages)
            {
                xmlWriter.WriteStartElement("message");
                xmlWriter.WriteAttributeString("text", m.Text);
                xmlWriter.WriteAttributeString("kind", m.Kind.ToString());
                xmlWriter.WriteEndElement();
            }

            xmlWriter.WriteEndElement();

	        xmlWriter.WriteEndElement();
	    }
        /// <summary>
        /// Processes a message for a server.
        /// </summary>
        /// <param name="serverSpecifer">The server the request is for.</param>
        /// <param name="action">The action to process.</param>
        /// <param name="message">The message containing the details of the request.</param>
        /// <returns>The response to the request.</returns>
        public string ProcessMessage(IServerSpecifier serverSpecifer, string action, string message)
        {
            // Normally this method just passes the request onto the remote server, but some messages
            // need to be intercepted and handled at the web dashboard level
            switch (action)
            {
            case "ListServers":
                // Generate the list of available servers - this is from the dashboard level
                var serverList = new DataListResponse
                {
                    Data = new List <string>()
                };
                foreach (var serverLocation in this.ServerLocations)
                {
                    serverList.Data.Add(serverLocation.Name);
                }

                // Return the XML of the list
                return(serverList.ToString());

            default:
                // Pass the request on
                var client   = this.GetCruiseManager(serverSpecifer, null);
                var response = client.ProcessMessage(action, message);
                return(response);
            }
        }
Esempio n. 16
0
        public ProjectGridRow[] GenerateProjectGridRows(IFarmService farmService, ProjectStatusOnServer[] statusList, string forceBuildActionName,
                                                        ProjectGridSortColumn sortColumn, bool sortIsAscending)
        {
            ArrayList rows = new ArrayList();

            foreach (ProjectStatusOnServer statusOnServer in statusList)
            {
                ProjectStatus     status           = statusOnServer.ProjectStatus;
                IServerSpecifier  serverSpecifier  = statusOnServer.ServerSpecifier;
                string            projectName      = status.Name;
                IProjectSpecifier projectSpecifier = new DefaultProjectSpecifier(serverSpecifier, projectName);

                string baseUrl = Regex.Replace(statusOnServer.ProjectStatus.WebURL, @"default\.aspx\?.*", "");

                string projectLink = baseUrl + linkFactory.CreateProjectLink(projectSpecifier, ProjectReportProjectPlugin.ACTION_NAME).Url;

                IBuildSpecifier[] buildSpecifiers = farmService.GetMostRecentBuildSpecifiers(projectSpecifier, 1);
                string            mostRecentBuildUrl;
                if (buildSpecifiers.Length == 1)
                {
                    mostRecentBuildUrl = baseUrl + linkFactory.CreateProjectLink(projectSpecifier, LatestBuildReportProjectPlugin.ACTION_NAME).Url;
                }
                else
                {
                    mostRecentBuildUrl = projectLink;
                }

                String[] logMessages    = farmService.GetLogMessages(projectSpecifier);
                String   lastLogMessage = String.Empty;
                if (logMessages.Length > 0)
                {
                    lastLogMessage = logMessages[logMessages.Length - 1];
                }

                rows.Add(
                    new ProjectGridRow(
                        projectName, statusOnServer.ServerSpecifier.ServerName, status.BuildStatus.ToString(),
                        CalculateHtmlColor(status.BuildStatus),
                        status.LastBuildDate,
                        status.LastBuildDuration,
                        (status.LastBuildLabel != null ? status.LastBuildLabel : "no build available"),
                        status.Status.ToString(),
                        status.Activity.ToString(),
                        urlBuilder.BuildFormName(forceBuildActionName),
                        projectLink,
                        mostRecentBuildUrl,
                        ChangeSet.Convert(status.Modifications),
                        status.Forcee,
                        status.CurrentBuildStartTime,
                        status.BuildCondition.ToString(),
                        lastLogMessage,
                        logMessages
                        ));
            }

            rows.Sort(GetComparer(sortColumn, sortIsAscending));

            return((ProjectGridRow[])rows.ToArray(typeof(ProjectGridRow)));
        }
Esempio n. 17
0
 public ProjectGridRow(ProjectStatus status, IServerSpecifier serverSpecifier,
                       string url, string parametersUrl, Translations translations)
 {
     this.status          = status;
     this.serverSpecifier = serverSpecifier;
     this.url             = url;
     this.parametersUrl   = parametersUrl;
 }
Esempio n. 18
0
 public ProjectGridRow(ProjectStatus status, IServerSpecifier serverSpecifier,
     string url, string parametersUrl, Translations translations)
 {
     this.status = status;
     this.serverSpecifier = serverSpecifier;
     this.url = url;
     this.parametersUrl = parametersUrl;
 }
 public IAbsoluteLink[] GetServerPluginLinks(IServerSpecifier serverSpecifier)
 {
     ArrayList links = new ArrayList();
     foreach (IPlugin plugin in pluginConfiguration.ServerPlugins)
     {
         links.Add(LinkFactory.CreateServerLink(serverSpecifier, plugin.LinkDescription, plugin.NamedActions[0].ActionName));
     }
     return (IAbsoluteLink[]) links.ToArray(typeof (IAbsoluteLink));
 }
Esempio n. 20
0
 protected void SetUp()
 {
     mockFarmService = new DynamicMock(typeof(IFarmService));
     mockRequest     = new DynamicMock(typeof(ICruiseRequest));
     serverSpecifier = new DefaultServerSpecifier("local");
     mockRequest.SetupResult("ServerSpecifier", serverSpecifier);
     mockRequest.SetupResult("ProjectName", "test");
     report = new ProjectXmlReport((IFarmService)mockFarmService.MockInstance, null);
 }
 protected void SetUp()
 {
     mockFarmService = new Mock <IFarmService>();
     mockRequest     = new Mock <ICruiseRequest>();
     serverSpecifier = new DefaultServerSpecifier("local");
     mockRequest.SetupGet(_request => _request.ServerSpecifier).Returns(serverSpecifier);
     mockRequest.SetupGet(_request => _request.ProjectName).Returns("test");
     report = new ProjectXmlReport((IFarmService)mockFarmService.Object, null);
 }
        /// <summary>
        /// Checks the security permissions for a user for a server.
        /// </summary>
        /// <param name="serverSpecifier">The server 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(IServerSpecifier serverSpecifier, string sessionToken, string userName)
        {
            var response = GetCruiseManager(serverSpecifier, sessionToken)
                           .DiagnoseSecurityPermissions(userName, new[] {
                string.Empty
            });

            return(response);
        }
 protected void SetUp()
 {
     mockFarmService = new DynamicMock(typeof (IFarmService));
     mockRequest = new DynamicMock(typeof (ICruiseRequest));
     serverSpecifier = new DefaultServerSpecifier("local");
     mockRequest.SetupResult("ServerSpecifier", serverSpecifier);
     mockRequest.SetupResult("ProjectName", "test");
     report = new ProjectXmlReport((IFarmService)mockFarmService.MockInstance, null);
 }
        public IAbsoluteLink[] GetServerPluginLinks(IServerSpecifier serverSpecifier)
        {
            var links = new List <IAbsoluteLink>();

            foreach (IPlugin plugin in pluginConfiguration.ServerPlugins)
            {
                links.Add(LinkFactory.CreateServerLink(serverSpecifier, plugin.LinkDescription, plugin.NamedActions[0].ActionName));
            }
            return(links.ToArray());
        }
		public IAbsoluteLink[] CreateServerLinkList(IServerSpecifier[] serverSpecifiers, string action)
		{
			var lstLinks = new List<IAbsoluteLink>();
			foreach (IServerSpecifier serverSpecifier in serverSpecifiers)
			{
				lstLinks.Add(linkFactory.CreateServerLink(serverSpecifier, action));
			}

			return lstLinks.ToArray();
		}
        public IAbsoluteLink[] CreateServerLinkList(IServerSpecifier[] serverSpecifiers, string action)
        {
            ArrayList lstLinks = new ArrayList();
            foreach (IServerSpecifier serverSpecifier in serverSpecifiers)
            {
                lstLinks.Add(linkFactory.CreateServerLink(serverSpecifier, action));
            }

            return (IAbsoluteLink[])lstLinks.ToArray(typeof(IAbsoluteLink));
        }
Esempio n. 27
0
        private string GetServerUrl(IServerSpecifier serverSpecifier)
        {
            foreach (ServerLocation serverLocation in ServerLocations)
            {
                if (serverLocation.Name == serverSpecifier.ServerName)
                {
                    return(serverLocation.Url);
                }
            }

            throw new UnknownServerException(serverSpecifier.ServerName);
        }
        private CruiseServerClientBase GetCruiseManager(IServerSpecifier serverSpecifier, string sessionToken)
        {
            var config = GetServerUrl(serverSpecifier);
            CruiseServerClientBase manager = clientFactory.GenerateClient(config.Url,
                                                                          new ClientStartUpSettings
            {
                BackwardsCompatable = config.BackwardCompatible
            });

            manager.SessionToken = sessionToken;
            return(manager);
        }
        public void ReturnsServerConfiguration()
        {
            ServerLocation[] servers = new ServerLocation[] { serverLocation, otherServerLocation };

            configurationMock.SetupGet(_configuration => _configuration.Servers).Returns(servers).Verifiable();

            IServerSpecifier specifier = managerWrapper.GetServerConfiguration("myserver");

            Assert.AreEqual(true, specifier.AllowForceBuild);

            VerifyAll();
        }
Esempio n. 30
0
        public void ReturnsServerConfiguration()
        {
            ServerLocation[] servers = new ServerLocation[] { serverLocation, otherServerLocation };

            configurationMock.ExpectAndReturn("Servers", servers);

            IServerSpecifier specifier = managerWrapper.GetServerConfiguration("myserver");

            Assert.AreEqual(true, specifier.AllowForceBuild);

            VerifyAll();
        }
Esempio n. 31
0
        public void Setup()
        {
            urlBuilderMock = mocks.Create <ICruiseUrlBuilder>().Object;
            Mock.Get(urlBuilderMock).Setup(_urlBuilderMock => _urlBuilderMock.BuildProjectUrl(It.IsAny <string>(), It.IsAny <IProjectSpecifier>()))
            .Returns("myLinkUrl");
            linkFactoryMock = new Mock <ILinkFactory>();
            projectGrid     = new ProjectGrid();

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

            projectLink = new GeneralAbsoluteLink("myLinkText", "myLinkUrl");
        }
        private ServerLocation GetServerUrl(IServerSpecifier serverSpecifier)
        {
            var locations = ServerLocations;

            foreach (var serverLocation in locations)
            {
                if (StringUtil.EqualsIgnoreCase(serverLocation.Name, serverSpecifier.ServerName))
                {
                    return(serverLocation);
                }
            }

            throw new UnknownServerException(serverSpecifier.ServerName);
        }
 public IResponse Execute(string actionName, IServerSpecifier serverSpecifier, ICruiseRequest request)
 {
     //Added code so since defaultServerSpecifier only sets the name of the server - not the actual config
     var serverName = serverSpecifier.ServerName;
     serverSpecifier = farmService.GetServerConfiguration(serverName);
     if (serverSpecifier == null)
     {
         throw new UnknownServerException(serverName);
     }
     else
     {
         return GenerateView(farmService.GetProjectStatusListAndCaptureExceptions(serverSpecifier, request.RetrieveSessionToken()), actionName, request, serverSpecifier);
     }
 }
		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");
		}
Esempio n. 35
0
        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 IResponse Execute(string actionName, IServerSpecifier serverSpecifier, ICruiseRequest request)
        {
            //Added code so since defaultServerSpecifier only sets the name of the server - not the actual config
            var serverName = serverSpecifier.ServerName;

            serverSpecifier = farmService.GetServerConfiguration(serverName);
            if (serverSpecifier == null)
            {
                throw new UnknownServerException(serverName);
            }
            else
            {
                return(GenerateView(farmService.GetProjectStatusListAndCaptureExceptions(serverSpecifier, request.RetrieveSessionToken()), actionName, request, serverSpecifier));
            }
        }
 private object GenerateSortLink(IServerSpecifier serverSpecifier, string action, ProjectGridSortColumn column, ProjectGridSortColumn currentColumn, bool currentReverse)
 {
     string queryString = "SortColumn=" + column.ToString();
     if (column == currentColumn && !currentReverse)
     {
         queryString += "&ReverseSort=ReverseSort";
     }
     if (serverSpecifier == null)
     {
         return urlBuilder.BuildUrl(action, queryString);
     }
     else
     {
         return cruiseUrlBuilder.BuildServerUrl(action, serverSpecifier, queryString);
     }
 }
		private object GenerateSortLink(IServerSpecifier serverSpecifier, string action, ProjectGridSortColumn column, ProjectGridSortColumn currentColumn, bool currentReverse)
		{
			string queryString = "SortColumn=" + column.ToString();
			if (column == currentColumn && !currentReverse)
			{
				queryString += "&ReverseSort=ReverseSort";
			}
			if (serverSpecifier == null)
			{
				return urlBuilder.BuildUrl(action, queryString);
			}
			else
			{
				return cruiseUrlBuilder.BuildServerUrl(action, serverSpecifier, queryString);
			}
		}
Esempio n. 39
0
 public DefaultProjectSpecifier(IServerSpecifier serverSpecifier, string projectName)
 {
     if (serverSpecifier == null)
     {
         throw new CruiseControlException("Project Specifier cannot be instantiated with a null Server Specifier");
     }
     if (projectName == null)
     {
         throw new CruiseControlException("Project Specifier cannot be instantiated with a null project name");
     }
     if (projectName == string.Empty)
     {
         throw new CruiseControlException("Project Specifier cannot be instantiated with an empty project name");
     }
     this.serverSpecifer = serverSpecifier;
     this.projectName    = projectName;
 }
 public DefaultProjectSpecifier(IServerSpecifier serverSpecifier, string projectName)
 {
     if (serverSpecifier == null)
     {
         throw new CruiseControlException("Project Specifier cannot be instantiated with a null Server Specifier");
     }
     if (projectName == null)
     {
         throw new CruiseControlException("Project Specifier cannot be instantiated with a null project name");
     }
     if (projectName == string.Empty)
     {
         throw new CruiseControlException("Project Specifier cannot be instantiated with an empty project name");
     }
     this.serverSpecifer = serverSpecifier;
     this.projectName = projectName;
 }
Esempio n. 41
0
        public IResponse Execute(ICruiseRequest cruiseRequest)
        {
            var branch = cruiseRequest.Request.FindParameterStartingWith("Branch");

            projectSpecifier     = cruiseRequest.ProjectSpecifier;
            retrieveSessionToken = cruiseRequest.RetrieveSessionToken();
            serverSpecifier      = cruiseRequest.ServerSpecifier;
            if (!string.IsNullOrEmpty(branch))
            {
                ChangeBranch(cruiseRequest.Request.GetText(branch));
            }
            SetBranchNames();
            Thread.Sleep(sleep);
            string project = cruiseManagerWrapper.GetProject(projectSpecifier, retrieveSessionToken);

            return(viewBuilder.GenerateAllBranchesView(projectSpecifier, retrieveSessionToken, GetCurrentBranch(project), GetBranchNames(project)));
        }
        private IAbsoluteLink[] GetCategoryLinks(IServerSpecifier serverSpecifier)
        {
            if (serverSpecifier == null)
            {
                return(null);
            }

            // create list of categories
            List <string> categories = new List <string>();

            foreach (ProjectStatusOnServer status in farmService
                     .GetProjectStatusListAndCaptureExceptions(serverSpecifier, request.RetrieveSessionToken())
                     .StatusAndServerList)
            {
                string category = status.ProjectStatus.Category;

                if (!string.IsNullOrEmpty(category) && !categories.Contains(category))
                {
                    categories.Add(category);
                }
            }

            // sort list if at least one element exists
            if (categories.Count == 0)
            {
                return(null);
            }
            else
            {
                categories.Sort();
            }

            // use just created list to assemble wanted links
            List <GeneralAbsoluteLink> links = new List <GeneralAbsoluteLink>();
            string urlTemplate = linkFactory
                                 .CreateServerLink(serverSpecifier, "ViewServerReport")
                                 .Url + "?Category=";

            foreach (string category in categories)
            {
                links.Add(new GeneralAbsoluteLink(category, urlTemplate + HttpUtility.UrlEncode(category)));
            }

            return(links.ToArray());
        }
Esempio n. 43
0
        public ProjectGridRow[] GenerateProjectGridRows(IFarmService farmService, ProjectStatusOnServer[] statusList, string forceBuildActionName,
                                                        ProjectGridSortColumn sortColumn, bool sortIsAscending)
        {
            ArrayList rows = new ArrayList();

            foreach (ProjectStatusOnServer statusOnServer in statusList)
            {
                ProjectStatus     status           = statusOnServer.ProjectStatus;
                IServerSpecifier  serverSpecifier  = statusOnServer.ServerSpecifier;
                string            projectName      = status.Name;
                IProjectSpecifier projectSpecifier = new DefaultProjectSpecifier(serverSpecifier, projectName);
                string            projectLink      = linkFactory.CreateProjectLink(projectSpecifier, ProjectReportProjectPlugin.ACTION_NAME).Url;

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

                rows.Add(
                    new ProjectGridRow(
                        projectName, statusOnServer.ServerSpecifier.ServerName, status.BuildStatus.ToString(),
                        CalculateHtmlColor(status.BuildStatus),
                        status.LastBuildDate,
                        (status.LastBuildLabel != null ? status.LastBuildLabel : "no build available"),
                        status.Status.ToString(),
                        status.Activity.ToString(),
                        urlBuilder.BuildFormName(forceBuildActionName),
                        projectLink,
                        mostRecentBuildUrl
                        ));
            }

            rows.Sort(GetComparer(sortColumn, sortIsAscending));

            return((ProjectGridRow[])rows.ToArray(typeof(ProjectGridRow)));
        }
		private HtmlFragmentResponse GenerateView(ProjectStatusListAndExceptions projectStatusListAndExceptions,
            string actionName, ICruiseRequest request, IServerSpecifier serverSpecifier)
		{
            this.translations = Translations.RetrieveCurrent();
            cruiseUrlBuilder = request.UrlBuilder;
            urlBuilder = request.UrlBuilder.InnerBuilder;
			Hashtable velocityContext = new Hashtable();
            velocityContext["forceBuildMessage"] = ForceBuildIfNecessary(request.Request);
            velocityContext["parametersCall"] = new ServerLink(cruiseUrlBuilder, new DefaultServerSpecifier("null"), string.Empty, ProjectParametersAction.ActionName).Url;

			velocityContext["wholeFarm"] = serverSpecifier == null ?  true : false;

			string category = request.Request.GetText("Category");
			velocityContext["showCategoryColumn"] = string.IsNullOrEmpty(category) ? true : false;

			ProjectGridSortColumn sortColumn = GetSortColumn(request.Request);
			bool sortReverse = SortAscending(request.Request);

			velocityContext["projectNameSortLink"] = GenerateSortLink(serverSpecifier, actionName, ProjectGridSortColumn.Name, sortColumn, sortReverse);
			velocityContext["buildStatusSortLink"] = GenerateSortLink(serverSpecifier, actionName, ProjectGridSortColumn.BuildStatus, sortColumn, sortReverse);
			velocityContext["lastBuildDateSortLink"] = GenerateSortLink(serverSpecifier, actionName, ProjectGridSortColumn.LastBuildDate, sortColumn, sortReverse);
			velocityContext["serverNameSortLink"] = GenerateSortLink(serverSpecifier, actionName, ProjectGridSortColumn.ServerName, sortColumn, sortReverse);
			velocityContext["projectCategorySortLink"] = GenerateSortLink(serverSpecifier, actionName, ProjectGridSortColumn.Category, sortColumn, sortReverse);

            ProjectGridRow[] projectGridRows = projectGrid.GenerateProjectGridRows(projectStatusListAndExceptions.StatusAndServerList, actionName, sortColumn, sortReverse, category, cruiseUrlBuilder, this.translations);

            velocityContext["projectGrid"] = projectGridRows;
			velocityContext["exceptions"] = projectStatusListAndExceptions.Exceptions;

            Array categoryList = this.GenerateCategoryList(projectGridRows);
            velocityContext["categoryList"] = categoryList;
            velocityContext["barAtTop"] = (this.SuccessIndicatorBarLocation == IndicatorBarLocation.Top) ||
                (this.SuccessIndicatorBarLocation == IndicatorBarLocation.TopAndBottom);
            velocityContext["barAtBottom"] = (this.SuccessIndicatorBarLocation == IndicatorBarLocation.Bottom) ||
                (this.SuccessIndicatorBarLocation == IndicatorBarLocation.TopAndBottom);

			return viewGenerator.GenerateView(@"ProjectGrid.vm", velocityContext);
		}
        private IAbsoluteLink[] GetCategoryLinks(IServerSpecifier[] serverSpecifiers, ICruiseRequest request)
        {
            if (serverSpecifiers == null) return null;

            List<string> categories = new List<string>();

            foreach (IServerSpecifier serverSpecifier in serverSpecifiers)
            {
                System.Diagnostics.Debug.WriteLine(serverSpecifier.ServerName);

                foreach (ProjectStatusOnServer status in farmService
                    .GetProjectStatusListAndCaptureExceptions(serverSpecifier, request.RetrieveSessionToken())
                    .StatusAndServerList)
                {
                    string category = status.ProjectStatus.Category;
                    System.Diagnostics.Debug.WriteLine(category);


                    if (!string.IsNullOrEmpty(category) && !categories.Contains(category))
                        categories.Add(category);
                }
            }

            // sort list if at least one element exists
            if (categories.Count == 0) return null;

            categories.Sort();

            // use just created list to assemble wanted links
            List<GeneralAbsoluteLink> links = new List<GeneralAbsoluteLink>();
            string urlTemplate = linkFactory.CreateFarmLink("Dashboard", ThoughtWorks.CruiseControl.WebDashboard.Plugins.FarmReport.FarmReportFarmPlugin.ACTION_NAME).Url + "?Category=";

            foreach (string category in categories)
                links.Add(new GeneralAbsoluteLink(category, urlTemplate + HttpUtility.UrlEncode(category)));

            return links.ToArray();
        }
 public bool IsAllowedForServer(IServerSpecifier serviceSpecifier)
 {
     return true;
 }
        private ProjectStatusListAndExceptions GetProjectStatusListAndCaptureExceptions(IServerSpecifier[] serverSpecifiers, string sessionToken)
        {
            var projectStatusOnServers = new List<ProjectStatusOnServer>();
            var exceptions = new List<CruiseServerException>();

            foreach (IServerSpecifier serverSpecifier in serverSpecifiers)
            {
                try
                {
                    var manager = GetCruiseManager(serverSpecifier, sessionToken);
                    foreach (ProjectStatus projectStatus in manager.GetProjectStatus())
                    {
                        projectStatusOnServers.Add(new ProjectStatusOnServer(projectStatus, serverSpecifier));
                    }
                }
                catch (SocketException)
                {
                    AddException(exceptions, serverSpecifier, new CruiseControlException("Unable to connect to CruiseControl.NET server.  Please either start the server or check the url."));
                }
                catch (Exception e)
                {
                    AddException(exceptions, serverSpecifier, e);
                }
            }

            return new ProjectStatusListAndExceptions(projectStatusOnServers.ToArray(), exceptions.ToArray());
        }
        private void AddException(List<CruiseServerException> exceptions, IServerSpecifier serverSpecifier, Exception e)
		{
			exceptions.Add(new CruiseServerException(serverSpecifier.ServerName, GetServerUrl(serverSpecifier).Url, e));
		}
		public string GetServerVersion(IServerSpecifier serverSpecifier, string sessionToken)
		{
            var response = GetCruiseManager(serverSpecifier, sessionToken)
                .GetServerVersion();
            return response;
		}
        public void AddProject(IServerSpecifier serverSpecifier, string serializedProject, string sessionToken)
		{
            GetCruiseManager(serverSpecifier, sessionToken).AddProject(serializedProject);
		}
        private CruiseServerClientBase GetCruiseManager(IServerSpecifier serverSpecifier, string sessionToken)
		{
            var config = GetServerUrl(serverSpecifier);
            CruiseServerClientBase manager = clientFactory.GenerateClient(config.Url,
                new ClientStartUpSettings
                {
                    BackwardsCompatable = config.BackwardCompatible
                });
            manager.SessionToken = sessionToken;
            return manager;
		}
        /// <summary>
        /// Processes a message for a server.
        /// </summary>
        /// <param name="serverSpecifer">The server the request is for.</param>
        /// <param name="action">The action to process.</param>
        /// <param name="message">The message containing the details of the request.</param>
        /// <returns>The response to the request.</returns>
        public string ProcessMessage(IServerSpecifier serverSpecifer, string action, string message)
        {
            // Normally this method just passes the request onto the remote server, but some messages
            // need to be intercepted and handled at the web dashboard level
            switch (action)
            {
                case "ListServers":
                    // Generate the list of available servers - this is from the dashboard level
                    var serverList = new DataListResponse
                    {
                        Data = new List<string>()
                    };
                    foreach (var serverLocation in this.ServerLocations)
                    {
                        serverList.Data.Add(serverLocation.Name);
                    }

                    // Return the XML of the list
                    return serverList.ToString();

                default:
                    // Pass the request on
                    var client = this.GetCruiseManager(serverSpecifer, null);
                    var response = client.ProcessMessage(action, message);
                    return response;
            }
        }
        private CruiseServerSnapshotListAndExceptions GetCruiseServerSnapshotListAndExceptions(IServerSpecifier[] serverSpecifiers, string sessionToken)
        {
            var cruiseServerSnapshotsOnServers = new List<CruiseServerSnapshotOnServer>();
            var exceptions = new List<CruiseServerException>();

            foreach (IServerSpecifier serverSpecifier in serverSpecifiers)
            {
                try
                {
                    var response = GetCruiseManager(serverSpecifier, sessionToken)
                        .GetCruiseServerSnapshot();
                    cruiseServerSnapshotsOnServers.Add(
                        new CruiseServerSnapshotOnServer(response, serverSpecifier));
                }
                catch (SocketException)
                {
                    AddException(exceptions, serverSpecifier, new CruiseControlException("Unable to connect to CruiseControl.NET server.  Please either start the server or check the url."));
                }
                catch (Exception e)
                {
                    AddException(exceptions, serverSpecifier, e);
                }
            }

            return new CruiseServerSnapshotListAndExceptions(
                cruiseServerSnapshotsOnServers.ToArray(),
                exceptions.ToArray());
        }
 /// <summary>
 /// Retrieves the configuration for security on a server.
 /// </summary>
 /// <param name="serverSpecifier">The server to get the configuration from.</param>
 /// <param name="sessionToken"></param>
 /// <returns>An XML fragment containing the security configuration.</returns>
 public virtual string GetServerSecurity(IServerSpecifier serverSpecifier, string sessionToken)
 {
     return GetCruiseManager(serverSpecifier, sessionToken)
         .GetSecurityConfiguration();
 }
 /// <summary>
 /// Lists all the users who have been defined on a server.
 /// </summary>
 /// <param name="serverSpecifier">The server to get the users from.</param>
 /// <param name="sessionToken"></param>
 /// <returns>
 /// A list of <see cref="UserDetails"/> containing the details on all the users
 /// who have been defined.
 /// </returns>
 public virtual List<UserDetails> ListAllUsers(IServerSpecifier serverSpecifier, string sessionToken)
 {
     var response = GetCruiseManager(serverSpecifier, sessionToken)
         .ListUsers();
     return response;
 }
Esempio n. 56
0
 public ProjectStatusOnServer(ProjectStatus projectStatus, IServerSpecifier serverSpecifier)
 {
     this.serverSpecifier = serverSpecifier;
     this.projectStatus = projectStatus;
 }
 /// <summary>
 /// Checks the security permissions for a user for a server.
 /// </summary>
 /// <param name="serverSpecifier">The server 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(IServerSpecifier serverSpecifier, string sessionToken, string userName)
 {
     var response = GetCruiseManager(serverSpecifier, sessionToken)
         .DiagnoseSecurityPermissions(userName, new[] {
             string.Empty
         });
     return response;
 }
 public CruiseServerSnapshotListAndExceptions GetCruiseServerSnapshotListAndExceptions(IServerSpecifier serverSpecifier, string sessionToken)
 {
     return GetCruiseServerSnapshotListAndExceptions(new[] { serverSpecifier }, sessionToken);
 }
 /// <summary>
 /// Retrieve the amount of free disk space.
 /// </summary>
 /// <returns></returns>
 public virtual long GetFreeDiskSpace(IServerSpecifier serverSpecifier)
 {
     var response = GetCruiseManager(serverSpecifier, null)
         .GetFreeDiskSpace();
     return Convert.ToInt64(response);
 }
 /// <summary>
 /// Reads the specified number of filtered audit events.
 /// </summary>
 /// <param name="startPosition">The starting position.</param>
 /// <param name="numberOfRecords">The number of records to read.</param>
 /// <param name="filter">The filter to use.</param>
 /// <param name="serverSpecifier"></param>
 /// <param name="sessionToken"></param>
 /// <returns>A list of <see cref="AuditRecord"/>s containing the audit details that match the filter.</returns>
 public virtual List<AuditRecord> ReadAuditRecords(IServerSpecifier serverSpecifier, string sessionToken, int startPosition, int numberOfRecords, AuditFilterBase filter)
 {
     var response = GetCruiseManager(serverSpecifier, sessionToken)
         .ReadAuditRecords(startPosition, numberOfRecords, filter);
     return response;
 }