/// <summary> /// Checks the internal validation of the item. /// </summary> /// <param name="configuration">The entire configuration.</param> /// <param name="parent">The parent item for the item being validated.</param> /// <param name="errorProcesser">The error processer to use.</param> public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { var parentProject = parent.GetAncestorValue <Project>(); if (parentProject != null) { // Attempt to find this publisher in the publishers section var isPublisher = false; foreach (var task in parentProject.Publishers) { if (task == this) { isPublisher = true; break; } } // If not found then throw a validation exception if (!isPublisher) { errorProcesser.ProcessWarning( "Email publishers are best placed in the publishers section of the configuration"); } } else { errorProcesser.ProcessError(new CruiseControlException("This publisher can only belong to a project")); } // Make sure the xslFiles are not empty if (this.xslFiles != null && this.XslFiles.Any(f => string.IsNullOrEmpty(f))) { errorProcesser.ProcessError("xslFiles cannot contain empty or null filenames"); } }
/// <summary> /// Checks the internal validation of the item. /// </summary> /// <param name="configuration">The entire configuration.</param> /// <param name="parent">The parent item for the item being validated.</param> /// <param name="errorProcesser">The error processer to use.</param> public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { if (string.IsNullOrEmpty(this.Url)) { errorProcesser.ProcessError("URL cannot be empty"); } if (string.IsNullOrEmpty(this.HeaderKey)) { errorProcesser.ProcessError("Header Key cannot be empty"); } }
/// <summary> /// Checks the internal validation of the item. /// </summary> /// <param name="configuration">The entire configuration.</param> /// <param name="parent">The parent item for the item being validated.</param> /// <param name="errorProcesser">The error processer to use.</param> public override void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { base.Validate(configuration, parent, errorProcesser); if (this.Verbose && this.Quiet) { errorProcesser.ProcessError("Cannot have both verbose and quiet set"); } if (this.ProfilerTimeOut < 0) { errorProcesser.ProcessError("profilerTimeout cannot be negative"); } }
/// <summary> /// Checks the internal validation of the item. /// </summary> /// <param name="configuration">The entire configuration.</param> /// <param name="parent">The parent item for the item being validated.</param> /// <param name="errorProcesser"></param> public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { var isInitialised = false; try { Initialise(); isInitialised = true; } catch (Exception error) { errorProcesser.ProcessError(error); } if (isInitialised) { foreach (IAuthentication user in this.loadedUsers.Values) { var config = user as IConfigurationValidation; if (config != null) { config.Validate(configuration, parent.Wrap(this), errorProcesser); } } foreach (IPermission permission in this.loadedPermissions.Values) { var config = permission as IConfigurationValidation; if (config != null) { config.Validate(configuration, parent.Wrap(this), errorProcesser); } } } }
/// <summary> /// Checks the internal validation of the item. /// </summary> /// <param name="configuration">The entire configuration.</param> /// <param name="parent">The parent item for the item being validated.</param> /// <param name="errorProcesser">The error processer to use.</param> public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { if (string.IsNullOrEmpty(this.Url)) { errorProcesser.ProcessError("URL cannot be empty"); } }
public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { if (this.MaximumValue <= 0) { errorProcesser.ProcessError( "The maximum value must be greater than zero"); } }
/// <summary> /// Checks the internal validation of the item. /// </summary> /// <param name="configuration">The entire configuration.</param> /// <param name="parent">The parent item for the item being validated.</param> /// <param name="errorProcesser">The error processer to use.</param> public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { if (!string.IsNullOrEmpty(refId)) { IPermission refPermission = configuration.SecurityManager.RetrievePermission(refId); if (refPermission == null) { errorProcesser.ProcessError(new BadReferenceException(refId)); } } }
/// <summary> /// Checks the internal validation of the item. /// </summary> /// <param name="configuration">The entire configuration.</param> /// <param name="parent">The parent item for the item being validated.</param> /// <param name="errorProcesser">The error processer to use.</param> public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { try { this.GetFBVersion(); this.GetFBPath(); } catch (Exception error) { errorProcesser.ProcessError(error); } }
public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { if (string.IsNullOrEmpty(this.MonitorFile)) { errorProcesser.ProcessError("File cannot be empty"); } else if (!File.Exists(this.MonitorFile)) { errorProcesser.ProcessWarning( "File '" + this.MonitorFile + "' does not exist"); } }
void IConfigurationValidation.Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { string projectName = "(Unknown)"; var project = parent.GetAncestorValue <Project>(); if (project != null) { projectName = project.Name; } if (integrationTime.Minutes + RandomOffSetInMinutesFromTime >= 60) { errorProcesser.ProcessError("Scheduled time {0}:{1} + randomOffSetInMinutesFromTime {2} would exceed the hour, this is not allowed. Conflicting project {3}", integrationTime.Hours, integrationTime.Minutes, RandomOffSetInMinutesFromTime, projectName); } }
public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { string ErrorInfo = "Invalid chars in TFS workspace name. Look at http://msdn.microsoft.com/en-us/library/aa980550.aspx#SourceControl for naming restrictions."; bool AllOk = true; System.Collections.Generic.List <string> badchars = new System.Collections.Generic.List <string>(); badchars.Add("/"); badchars.Add(":"); badchars.Add("<"); badchars.Add(">"); badchars.Add("|"); badchars.Add(@"\"); badchars.Add("*"); badchars.Add("?"); badchars.Add(";"); if (workspaceName.Length > 64) { AllOk = false; ErrorInfo += System.Environment.NewLine + "Max length is 64 chars"; } if (workspaceName.EndsWith(" ")) { AllOk = false; ErrorInfo += System.Environment.NewLine + "can not end with space"; } foreach (string s in badchars) { if (workspaceName.Contains(s)) { AllOk = false; ErrorInfo += System.Environment.NewLine + "can not contain character " + s; } } if (!AllOk) { errorProcesser.ProcessError(ErrorInfo); } }
/// <summary> /// Checks the internal validation of the item. /// </summary> /// <param name="configuration">The entire configuration.</param> /// <param name="parent">The parent item for the item being validated.</param> /// <param name="errorProcesser">The error processer to use.</param> public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { if ((this.Conditions == null) || (this.Conditions.Length == 0)) { errorProcesser .ProcessError("Validation failed for andCondition - at least one child condition must be supplied"); } else { foreach (var child in this.Conditions.OfType <IConfigurationValidation>()) { child.Validate( configuration, parent.Wrap(this), errorProcesser); } } }
/// <summary> /// Checks the internal validation of the item. /// </summary> /// <param name="configuration">The entire configuration.</param> /// <param name="parent">The parent item for the item being validated.</param> /// <param name="errorProcesser"></param> public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { // Ensure that the queue has at least one project in it var queueFound = false; foreach (IProject projectDef in configuration.Projects) { if (string.Equals(this.Name, projectDef.QueueName, StringComparison.InvariantCulture)) { queueFound = true; break; } } if (!queueFound) { errorProcesser.ProcessError(new ConfigurationException( string.Format(System.Globalization.CultureInfo.CurrentCulture, "An unused queue definition has been found: name '{0}'", this.Name))); } }
private void LoadAndValidateProject(IConfigurationErrorProcesser errorProcesser, List <string> projectNames, Configuration configuration, object loadedItem) { IProject project = loadedItem as IProject; // Validate that the project name is unique string projectName = project.Name.ToLowerInvariant(); if (projectNames.Contains(projectName)) { errorProcesser.ProcessError( new CruiseControlException( string.Format( CultureInfo.CurrentCulture, "A duplicate project name ({0})has been found - projects must be unique per server", projectName))); } else { projectNames.Add(projectName); } configuration.AddProject(project); }
/// <summary> /// Checks the internal validation of the item. /// </summary> /// <param name="configuration">The entire configuration.</param> /// <param name="parent">The parent item for the item being validated.</param> /// <param name="errorProcesser">The error processer to use.</param> public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { if ((this.Conditions == null) || (this.Conditions.Length == 0)) { errorProcesser .ProcessError("Validation failed for andCondition - at least one child condition must be supplied"); } else { foreach (var child in this.Conditions.OfType<IConfigurationValidation>()) { child.Validate( configuration, parent.Wrap(this), errorProcesser); } } }
public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { string ErrorInfo = "Invalid chars in TFS workspace name. Look at http://msdn.microsoft.com/en-us/library/aa980550.aspx#SourceControl for naming restrictions."; bool AllOk = true; System.Collections.Generic.List<string> badchars = new System.Collections.Generic.List<string>(); badchars.Add("/"); badchars.Add(":"); badchars.Add("<"); badchars.Add(">"); badchars.Add("|"); badchars.Add(@"\"); badchars.Add("*"); badchars.Add("?"); badchars.Add(";"); if (workspaceName.Length > 64) { AllOk = false; ErrorInfo += System.Environment.NewLine + "Max length is 64 chars"; } if (workspaceName.EndsWith(" ")) { AllOk = false; ErrorInfo += System.Environment.NewLine + "can not end with space"; } foreach (string s in badchars) { if (workspaceName.Contains(s)) { AllOk = false; ErrorInfo += System.Environment.NewLine + "can not contain character " + s; } } if (!AllOk) errorProcesser.ProcessError(ErrorInfo); }
/// <summary> /// Checks the internal validation of the item. /// </summary> /// <param name="configuration">The entire configuration.</param> /// <param name="parent">The parent item for the item being validated.</param> /// <param name="errorProcesser">The error processer to use.</param> public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { var parentProject = parent.GetAncestorValue<Project>(); if (parentProject != null) { // Attempt to find this publisher in the publishers section var isPublisher = false; foreach (var task in parentProject.Publishers) { if (task == this) { isPublisher = true; break; } } // If not found then throw a validation exception if (!isPublisher) { errorProcesser.ProcessWarning("Email publishers are best placed in the publishers section of the configuration"); } } else { errorProcesser.ProcessError( new CruiseControlException("This publisher can only belong to a project")); } }
private void LoadAndValidateProject(IConfigurationErrorProcesser errorProcesser, List<string> projectNames, Configuration configuration, object loadedItem) { IProject project = loadedItem as IProject; // Validate that the project name is unique string projectName = project.Name.ToLowerInvariant(); if (projectNames.Contains(projectName)) { errorProcesser.ProcessError( new CruiseControlException( string.Format( "A duplicate project name ({0})has been found - projects must be unique per server", projectName))); } else { projectNames.Add(projectName); } configuration.AddProject(project); }
void IConfigurationValidation.Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { string projectName = "(Unknown)"; var project = parent.GetAncestorValue<Project>(); if (project != null) { projectName = project.Name; } if (integrationTime.Minutes + RandomOffSetInMinutesFromTime >= 60) { errorProcesser.ProcessError("Scheduled time {0}:{1} + randomOffSetInMinutesFromTime {2} would exceed the hour, this is not allowed. Conflicting project {3}", integrationTime.Hours, integrationTime.Minutes, RandomOffSetInMinutesFromTime, projectName); } }
/// <summary> /// Checks the internal validation of the item. /// </summary> /// <param name="configuration">The entire configuration.</param> /// <param name="parent">The parent item for the item being validated.</param> /// <param name="errorProcesser"></param> public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { // Ensure that the queue has at least one project in it var queueFound = false; foreach (IProject projectDef in configuration.Projects) { if (string.Equals(this.Name, projectDef.QueueName, StringComparison.InvariantCulture)) { queueFound = true; break; } } if (!queueFound) { errorProcesser.ProcessError(new ConfigurationException( string.Format(System.Globalization.CultureInfo.CurrentCulture,"An unused queue definition has been found: name '{0}'", this.Name))); } }
/// <summary> /// Checks the internal validation of the item. /// </summary> /// <param name="configuration">The entire configuration.</param> /// <param name="parent">The parent item for the item being validated.</param> /// <param name="errorProcesser"></param> public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { var isInitialised = false; try { Initialise(); isInitialised = true; } catch (Exception error) { errorProcesser.ProcessError(error); } if (isInitialised) { foreach (IAuthentication user in this.loadedUsers.Values) { if (user is IConfigurationValidation) { (user as IConfigurationValidation).Validate(configuration, parent.Wrap(this), errorProcesser); } } foreach (IPermission permission in this.loadedPermissions.Values) { if (permission is IConfigurationValidation) { (permission as IConfigurationValidation).Validate(configuration, parent.Wrap(this), errorProcesser); } } } }
/// <summary> /// Checks the internal validation of the item. /// </summary> /// <param name="configuration">The entire configuration.</param> /// <param name="parent">The parent item for the item being validated.</param> /// <param name="errorProcesser">The error processer to use.</param> public void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { if (string.IsNullOrEmpty(AwsAccessKey)) { errorProcesser.ProcessError("awsAccessKey cannot be empty"); } if (string.IsNullOrEmpty(AwsSecretAccessKey)) { errorProcesser.ProcessError("awsSecretAccessKey cannot be empty"); } if (!Uri.IsWellFormedUriString(QueueUrl, UriKind.Absolute)) { errorProcesser.ProcessError("queueUrl is not well-formed"); } }
/// <summary> /// Checks the internal validation of the item. /// </summary> /// <param name="configuration">The entire configuration.</param> /// <param name="parent">The parent item for the item being validated.</param> /// <param name="errorProcesser"></param> public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { if (security.RequiresServerSecurity && (configuration.SecurityManager is NullSecurityManager)) { errorProcesser.ProcessError( new ConfigurationException( string.Format(System.Globalization.CultureInfo.CurrentCulture, "Security is defined for project '{0}', but not defined at the server", this.Name))); } this.ValidateProject(errorProcesser); this.ValidateItem(sourceControl, configuration, parent, errorProcesser); this.ValidateItem(labeller, configuration, parent, errorProcesser); this.ValidateItems(PrebuildTasks, configuration, parent, errorProcesser); this.ValidateItems(tasks, configuration, parent, errorProcesser); this.ValidateItems(publishers, configuration, parent, errorProcesser); this.ValidateItem(state, configuration, parent, errorProcesser); this.ValidateItem(security, configuration, parent, errorProcesser); var mt = (MultipleTrigger)this.Triggers; if (mt != null) { this.ValidateItems(mt.Triggers, configuration, parent, errorProcesser); } this.configuration = configuration; }
/// <summary> /// Checks the internal validation of the item. /// </summary> /// <param name="configuration">The entire configuration.</param> /// <param name="parent">The parent item for the item being validated.</param> /// <param name="errorProcesser">The error processer to use.</param> public virtual void Validate(IConfiguration configuration, ConfigurationTrace parent, IConfigurationErrorProcesser errorProcesser) { var parentProject = parent.GetAncestorValue<Project>(); if (parentProject != null) { // Attempt to find this publisher in the publishers section var isPublisher = false; foreach (var task in parentProject.Publishers) { if (task == this) { isPublisher = true; break; } } // If not found then throw a validation exception if (!isPublisher) { errorProcesser.ProcessWarning( "Email publishers are best placed in the publishers section of the configuration"); } } else { errorProcesser.ProcessError(new CruiseControlException("This publisher can only belong to a project")); } // Make sure the xslFiles are not empty if (this.xslFiles != null && this.XslFiles.Any(f => string.IsNullOrEmpty(f))) { errorProcesser.ProcessError("xslFiles cannot contain empty or null filenames"); } }