/// <summary>
 /// Adds a project to the server
 /// </summary>
 public void AddProject(string serializedProject)
 {
     ChangeConfigurationRequest request = new ChangeConfigurationRequest();
     request.ProjectDefinition = serializedProject;
     Response resp = cruiseServer.AddProject(request);
     ValidateResponse(resp);
 }
 public void ToStringSerialisesAllValues()
 {
     ChangeConfigurationRequest request = new ChangeConfigurationRequest();
     request.Identifier = "identifier";
     request.ServerName = "serverName";
     request.SessionToken = "sessionToken";
     request.SourceName = "sourceName";
     request.Timestamp = DateTime.Now;
     request.ProjectDefinition = "Build#1";
     request.PurgeArtifactDirectory = true;
     request.PurgeSourceControlEnvironment = true;
     request.PurgeWorkingDirectory = true;
     string actual = request.ToString();
     string expected = string.Format(System.Globalization.CultureInfo.CurrentCulture,"<changeConfigurationRequest xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
         "timestamp=\"{4:yyyy-MM-ddTHH:mm:ss.FFFFFFFzzz}\" identifier=\"{0}\" server=\"{1}\" source=\"{2}\" session=\"{3}\" " +
         "purgeWorking=\"true\" purgeArtifact=\"true\" purgeSourceControl=\"true\">" + 
         "<definition>Build#1</definition>" + 
         "</changeConfigurationRequest>",
         request.Identifier,
         request.ServerName,
         request.SourceName,
         request.SessionToken,
         request.Timestamp);
     Assert.AreEqual(expected, actual);
 }
 /// <summary>
 /// Deletes the specified project from the server
 /// </summary>
 public void DeleteProject(string projectName, bool purgeWorkingDirectory, bool purgeArtifactDirectory, bool purgeSourceControlEnvironment)
 {
     ChangeConfigurationRequest request = new ChangeConfigurationRequest(null, projectName);
     request.PurgeWorkingDirectory = purgeWorkingDirectory;
     request.PurgeArtifactDirectory = purgeArtifactDirectory;
     request.PurgeSourceControlEnvironment = purgeSourceControlEnvironment;
     Response resp = cruiseServer.DeleteProject(request);
     ValidateResponse(resp);
 }
 public void InitialiseRequestWithSessionSetsTheCorrectValues()
 {
     string sessionToken = "the session";
     DateTime now = DateTime.Now;
     ChangeConfigurationRequest request = new ChangeConfigurationRequest(sessionToken);
     Assert.IsFalse(string.IsNullOrEmpty(request.Identifier), "Identifier was not set");
     Assert.AreEqual(Environment.MachineName, request.SourceName, "Source name doesn't match the machine name");
     Assert.AreEqual(sessionToken, request.SessionToken, "SessionToken doesn't match the input token");
     Assert.IsTrue((now <= request.Timestamp), "Timestamp was not set");
 }
 public void ToStringSerialisesDefaultValues()
 {
     ChangeConfigurationRequest request = new ChangeConfigurationRequest();
     string actual = request.ToString();
     string expected = string.Format(System.Globalization.CultureInfo.CurrentCulture,"<changeConfigurationRequest xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
         "timestamp=\"{2:yyyy-MM-ddTHH:mm:ss.FFFFFFFzzz}\" identifier=\"{0}\" source=\"{1}\" " +
         "purgeWorking=\"false\" purgeArtifact=\"false\" purgeSourceControl=\"false\" />",
         request.Identifier,
         request.SourceName,
         request.Timestamp);
     Assert.AreEqual(expected, actual);
 }
 public void GetSetAllPropertiesWorks()
 {
     ChangeConfigurationRequest request = new ChangeConfigurationRequest();
     request.ProjectDefinition = "Build#1";
     Assert.AreEqual("Build#1", request.ProjectDefinition, "ProjectDefinition fails the get/set test");
     request.PurgeArtifactDirectory = true;
     Assert.IsTrue(request.PurgeArtifactDirectory, "PurgeArtifactDirectory fails the get/set test");
     request.PurgeSourceControlEnvironment = true;
     Assert.IsTrue(request.PurgeSourceControlEnvironment, "PurgeSourceControlEnvironment fails the get/set test");
     request.PurgeWorkingDirectory = true;
     Assert.IsTrue(request.PurgeWorkingDirectory, "PurgeWorkingDirectory fails the get/set test");
 }
 /// <summary>
 /// Adds a project to the server
 /// </summary>
 public override void AddProject(string serializedProject)
 {
     ChangeConfigurationRequest request = new ChangeConfigurationRequest();
     request.SessionToken = SessionToken;
     request.ProjectDefinition = serializedProject;
     request.ServerName = TargetServer;
     Response resp = connection.SendMessage("AddProject", request);
     ValidateResponse(resp);
 }
        /// <summary>
        /// Updates the selected project on the server
        /// </summary>
        public override void UpdateProject(string projectName, string serializedProject)
        {
            if (string.IsNullOrEmpty(projectName)) throw new ArgumentNullException("projectName");

            ChangeConfigurationRequest request = new ChangeConfigurationRequest(SessionToken, projectName);
            request.ProjectDefinition = serializedProject;
            request.ServerName = TargetServer;
            Response resp = connection.SendMessage("UpdateProject", request);
            ValidateResponse(resp);
        }
        /// <summary>
        /// Deletes the specified project from the server
        /// </summary>
        public override void DeleteProject(string projectName, bool purgeWorkingDirectory, bool purgeArtifactDirectory, bool purgeSourceControlEnvironment)
        {
            if (string.IsNullOrEmpty(projectName)) throw new ArgumentNullException("projectName");

            ChangeConfigurationRequest request = new ChangeConfigurationRequest(SessionToken, projectName);
            request.PurgeWorkingDirectory = purgeWorkingDirectory;
            request.PurgeArtifactDirectory = purgeArtifactDirectory;
            request.PurgeSourceControlEnvironment = purgeSourceControlEnvironment;
            request.ServerName = TargetServer;
            Response resp = connection.SendMessage("DeleteProject", request);
            ValidateResponse(resp);
        }
 /// <summary>
 /// Updates the selected project on the server
 /// </summary>
 public virtual Response UpdateProject(ChangeConfigurationRequest request)
 {
     return cruiseServer.UpdateProject(request);
 }
        /// <summary>
        /// Updates the selected project on the server
        /// </summary>
		public void UpdateProject(string projectName, string serializedProject)
		{
            ChangeConfigurationRequest request = new ChangeConfigurationRequest(null, projectName);
            request.ProjectDefinition = serializedProject;
            Response resp = cruiseServer.UpdateProject(request);
            ValidateResponse(resp);
		}
 /// <summary>
 /// Updates the selected project on the server
 /// </summary>
 public virtual Response UpdateProject(ChangeConfigurationRequest request)
 {
     Response response = RunProjectRequest(request,
         SecurityPermission.ChangeProjectConfiguration,
         SecurityEvent.UpdateProject,
         delegate
         {
             Log.Info("Updating project - " + request.ProjectName);
             try
             {
                 IConfiguration configuration = configurationService.Load();
                 configuration.Projects[request.ProjectName].Purge(true, false, true);
                 configuration.DeleteProject(request.ProjectName);
                 IProject project = projectSerializer.Deserialize(request.ProjectDefinition);
                 configuration.AddProject(project);
                 project.Initialize();
                 configurationService.Save(configuration);
             }
             catch (ApplicationException e)
             {
                 Log.Warning(e);
                 throw new CruiseControlException("Failed to add project. Exception was - " + e.Message, e);
             }
         });
     return response;
 }
 /// <summary>
 /// Deletes the specified project from the server
 /// </summary>
 public virtual Response DeleteProject(ChangeConfigurationRequest request)
 {
     Response response = RunProjectRequest(request,
         SecurityPermission.ChangeProjectConfiguration,
         SecurityEvent.DeleteProject,
         delegate
         {
             Log.Info("Deleting project - " + request.ProjectName);
             try
             {
                 IConfiguration config = configurationService.Load();
                 config.Projects[request.ProjectName]
                     .Purge(request.PurgeWorkingDirectory,
                         request.PurgeArtifactDirectory,
                         request.PurgeSourceControlEnvironment);
                 config.DeleteProject(request.ProjectName);
                 configurationService.Save(config);
             }
             catch (Exception e)
             {
                 Log.Warning(e);
                 throw new CruiseControlException("Failed to delete project. Exception was - " + e.Message, e);
             }
         });
     return response;
 }
 /// <summary>
 /// Deletes the specified project from the server
 /// </summary>
 public virtual Response DeleteProject(ChangeConfigurationRequest request)
 {
     return server.DeleteProject(request);
 }