public void HandleConnectionError(Exception exception, PluginProfileErrorCollection errors) { _log.GetLogger("Mercurial").Warn("Check connection failed", exception); exception = exception.InnerException ?? exception; const string uriFieldName = "Uri"; if (exception is MercurialExecutionException) { errors.Add(new PluginProfileError { FieldName = "Login", Message = ExtractValidErrorMessage(exception)}); errors.Add(new PluginProfileError { FieldName = "Password", Message = ExtractValidErrorMessage(exception) }); errors.Add(new PluginProfileError { FieldName = uriFieldName, Message = ExtractValidErrorMessage(exception) }); return; } if (exception is ArgumentNullException || exception is DirectoryNotFoundException) { errors.Add(new PluginProfileError{ FieldName = uriFieldName, Message = INVALID_URI_OR_INSUFFICIENT_ACCESS_RIGHTS_ERROR_MESSAGE }); } if (exception is MercurialMissingException) { errors.Add(new PluginProfileError { Message = MERCURIAL_IS_NOT_INSTALLED_ERROR_MESSAGE }); } var fieldName = string.Empty; if (exception is InvalidRevisionException) { fieldName = "Revision"; } errors.Add(new PluginProfileError {FieldName = fieldName, Message = exception.Message}); }
public void HandleConnectionError(Exception exception, PluginProfileErrorCollection errors) { _log.GetLogger("Git").Warn("Check connection failed", exception); exception = exception.InnerException ?? exception; const string uriFieldName = "Uri"; if (exception is TransportException) { errors.Add(new PluginProfileError {FieldName = "Login", Message = exception.Message}); errors.Add(new PluginProfileError {FieldName = "Password", Message = exception.Message}); errors.Add(new PluginProfileError {FieldName = uriFieldName, Message = exception.Message}); return; } if (exception is ArgumentNullException) { errors.Add(new PluginProfileError{FieldName = uriFieldName, Message = INVALID_URI_OR_INSUFFICIENT_ACCESS_RIGHTS_ERROR_MESSAGE}); } var fieldName = string.Empty; if (exception is JGitInternalException) { if (exception.Message.ToLower().Contains("invalid remote") || exception.Message.ToLower().Contains("uri")) { fieldName = uriFieldName; } } if (exception is InvalidRevisionException) { fieldName = "Revision"; } errors.Add(new PluginProfileError {FieldName = fieldName, Message = exception.Message}); }
public void HandleConnectionError(Exception exception, PluginProfileErrorCollection errors) { _log.GetLogger("Tfs").Warn("Check connection failed", exception); exception = exception.InnerException ?? exception; const string uriFieldName = "Uri"; if (exception is TeamFoundationServiceException) { errors.Add(new PluginProfileError { FieldName = "Login", Message = exception.Message }); errors.Add(new PluginProfileError { FieldName = "Password", Message = exception.Message }); errors.Add(new PluginProfileError { FieldName = uriFieldName, Message = exception.Message }); return; } if (exception is ArgumentNullException || exception is DirectoryNotFoundException) { errors.Add(new PluginProfileError { FieldName = uriFieldName, Message = INVALID_URI_OR_INSUFFICIENT_ACCESS_RIGHTS_ERROR_MESSAGE }); } var fieldName = string.Empty; if (exception is InvalidRevisionException) { fieldName = "Revision"; } errors.Add(new PluginProfileError { FieldName = fieldName, Message = exception.Message }); }
protected override void ExecuteConcreate(PluginProfileErrorCollection errors) { try { var url = new BugzillaUrl(ConnectionSettings); WebClient webClient = new TpWebClient(errors) { Encoding = Encoding.UTF8 }; webClient.DownloadString(url.Url); } catch (WebException webException) { if (webException.Status != WebExceptionStatus.TrustFailure) { errors.Add(new PluginProfileError { FieldName = BugzillaProfile.UrlField, Message = webException.Message, AdditionalInfo = ValidationErrorType.BugzillaNotFound.ToString() }); } } catch (Exception exception) { errors.Add(new PluginProfileError { FieldName = BugzillaProfile.UrlField, Message = exception.Message, AdditionalInfo = ValidationErrorType.BugzillaNotFound.ToString() }); } }
private static void AddCredentialsErrors(PluginProfileErrorCollection errors) { errors.Add(new PluginProfileError { FieldName = ConnectionSettings.LoginField, Message = "Check credentials" }); errors.Add(new PluginProfileError { FieldName = ConnectionSettings.PasswordField, Message = "Check credentials" }); }
private static void AddConnectionErrors(PluginProfileErrorCollection errors) { errors.Add(new PluginProfileError { FieldName = ConnectionSettings.PortField, Message = "Check connection settings" }); errors.Add(new PluginProfileError { FieldName = ConnectionSettings.MailServerField, Message = "Check connection settings" }); }
private static void HandleConnectionError(SvnException e, PluginProfileErrorCollection errors) { if (e is SvnAuthorizationException) { errors.Add(ErrorFor(ConnectionSettings.LoginField, "Authorization failed")); errors.Add(ErrorFor(ConnectionSettings.PasswordField)); } else if (e is SvnAuthenticationException || e.RootCause is SvnAuthenticationException) { errors.Add(ErrorFor(ConnectionSettings.LoginField, "Authentication failed")); errors.Add(ErrorFor(ConnectionSettings.PasswordField)); } else if (e.Message.Contains("200 OK")) { errors.Add(ErrorFor(ConnectionSettings.UriField, "Invalid path to repository")); } else if (e is SvnRepositoryIOException) { errors.Add(ErrorFor(ConnectionSettings.UriField, "Could not connect to server")); } else if (e is SvnFileSystemException || e is SvnClientUnrelatedResourcesException) { errors.Add(ErrorFor(SubversionPluginProfile.StartRevisionField)); } else { errors.Add(ErrorFor(ConnectionSettings.UriField, e.Message.Fmt("Connection failed. {0}"))); } }
private void ValidateCommand(PluginProfileErrorCollection errors) { if(CommandName.IsNullOrWhitespace()) { errors.Add(new PluginProfileError { FieldName = "CommandName", Message = "Command name shoud not be empty" }); } }
private void ValidateTasksList(PluginProfileErrorCollection errors) { if(TasksList.IsNullOrWhitespace()) { errors.Add(new PluginProfileError { FieldName = "TasksList", Message = "Task list shoud not be empty" }); } }
private void ValidateAuthTokenUserId(PluginProfileErrorCollection errors) { if (AuthTokenUserId <= 0) { errors.Add(new PluginProfileError { FieldName = "AuthTokenUserId", Message = "User for authentication should be specified" }); } }
private void ValidateProject(PluginProfileErrorCollection errors) { if (Project <= 0) { errors.Add(new PluginProfileError { FieldName = "Project", Message = "Project should be specified" }); } }
private void ValidateNameIsNotEmpty(PluginProfileErrorCollection errors) { if (_dto.Name.IsNullOrWhitespace()) { errors.Add(new PluginProfileError {FieldName = "Name", Message = "Profile Name is required"}); } }
private void ValidatePassword(PluginProfileErrorCollection errors) { if (Password.IsNullOrWhitespace()) { errors.Add(new PluginProfileError { FieldName = "Password", Message = "Password should not be empty" }); } }
public void HandleConnectionError(Exception exception, PluginProfileErrorCollection errors) { _log.GetLogger("Git").Warn("Check connection failed", exception); exception = exception.InnerException ?? exception; const string uriFieldName = "Uri"; if (exception is TransportException) { errors.Add(new PluginProfileError { FieldName = "Login", Message = exception.Message }); errors.Add(new PluginProfileError { FieldName = "Password", Message = exception.Message }); errors.Add(new PluginProfileError { FieldName = uriFieldName, Message = exception.Message }); return; } if (exception is ArgumentNullException) { errors.Add(new PluginProfileError { FieldName = uriFieldName, Message = INVALID_URI_OR_INSUFFICIENT_ACCESS_RIGHTS_ERROR_MESSAGE }); } var fieldName = string.Empty; if (exception is JGitInternalException) { if (exception.Message.ToLower().Contains("invalid remote") || exception.Message.ToLower().Contains("uri")) { fieldName = uriFieldName; } } if (exception is InvalidRevisionException) { fieldName = "Revision"; } errors.Add(new PluginProfileError { FieldName = fieldName, Message = exception.Message }); }
protected override void ExecuteConcreate(PluginProfileErrorCollection errors) { try { Data = new BugzillaParser <bugzilla_properties>().Parse(_dataHolder.Data); } catch (InvalidOperationException) { errors.Add(new PluginProfileError { FieldName = BugzillaProfile.LoginField, Message = "The credentials are invalid.", AdditionalInfo = ValidationErrorType.InvalidCredentials.ToString() }); errors.Add(new PluginProfileError { FieldName = BugzillaProfile.PasswordField, Message = "The credentials are invalid.", AdditionalInfo = ValidationErrorType.InvalidCredentials.ToString() }); } }
private static PluginProfileErrorCollection Add(PluginProfileErrorCollection errors, Exception e) { errors.Add(new PluginProfileError { Message = e.Message }); return errors; }
private void ValidatePassword(PluginProfileErrorCollection errors) { if (string.IsNullOrEmpty(Password)) { errors.Add(new PluginProfileError { FieldName = PasswordField, Message = "Password is required" }); } }
private void ValidateQueries(PluginProfileErrorCollection errors) { if (string.IsNullOrEmpty(SavedSearches)) { errors.Add(new PluginProfileError { FieldName = QueriesField, Message = "Saved Search is required" }); } }
private void ValidateUrl(PluginProfileErrorCollection errors) { if (string.IsNullOrEmpty(Url)) { errors.Add(new PluginProfileError { FieldName = UrlField, Message = "URL is required" }); } }
private void ValidateProject(PluginProfileErrorCollection errors) { if (Project <= 0) { errors.Add(new PluginProfileError { FieldName = ProjectField, Message = "Project is required" }); } }
private void ValidateLogin(PluginProfileErrorCollection errors) { if (string.IsNullOrEmpty(Login)) { errors.Add(new PluginProfileError { FieldName = LoginField, Message = "Login is required" }); } }
private void ValidateMailServer(PluginProfileErrorCollection errors) { if (MailServer.IsNullOrWhitespace()) { errors.Add(new PluginProfileError { FieldName = "MailServer", Message = "Server should not be empty" }); } }
private void ValidateUriIsNotSsh(PluginProfileErrorCollection errors) { if (!string.IsNullOrEmpty(Uri) && Uri.StartsWith("svn+ssh://", StringComparison.OrdinalIgnoreCase)) { errors.Add(new PluginProfileError { FieldName = UriField, Message = "Connection via SSH is not supported." }); } }
private void ValidateRemoteResultsUrl(PluginProfileErrorCollection errors) { if (string.IsNullOrEmpty(RemoteResultsUrl) || string.IsNullOrEmpty(RemoteResultsUrl.Trim())) { errors.Add(new PluginProfileError { FieldName = "RemoteResultsUrl", Message = string.Empty }); } }
private void ValidateUriIsNotEmpty(PluginProfileErrorCollection errors) { if (string.IsNullOrEmpty(Uri)) { errors.Add(new PluginProfileError { FieldName = UriField, Message = "URI should not be empty." }); } }
private void ValidateTestPlan(PluginProfileErrorCollection errors) { if (TestPlan <= 0) { errors.Add(new PluginProfileError { FieldName = "TestPlan", Message = "Test Plan should be specified" }); } }
private void ValidateFramework(PluginProfileErrorCollection errors) { if (FrameworkType == FrameworkTypes.FrameworkTypes.None) { errors.Add(new PluginProfileError { FieldName = "FrameworkType", Message = "Framework type should be specified" }); } }
protected void ValidateNameNotEmpty(PluginProfileErrorCollection errors) { if (string.IsNullOrWhiteSpace(Name)) errors.Add(new PluginProfileError { FieldName = NameField, Message = "Mashup name cannot be empty or consist of whitespace characters only" }); }
private void ValidateProtocol(PluginProfileErrorCollection errors) { if (Protocol.IsNullOrWhitespace()) { errors.Add(new PluginProfileError { FieldName = "Protocol", Message = "Protocol should not be empty" }); } }
private void ValidateCommand(PluginProfileErrorCollection errors) { if (CommandName.IsNullOrWhitespace()) { errors.Add(new PluginProfileError { FieldName = "CommandName", Message = "Command name shoud not be empty" }); } }
private void ValidatePort(PluginProfileErrorCollection errors) { if (Port <= 0) { errors.Add(new PluginProfileError { FieldName = "Port", Message = "Port should not be empty" }); } }
private void ValidateTasksList(PluginProfileErrorCollection errors) { if (TasksList.IsNullOrWhitespace()) { errors.Add(new PluginProfileError { FieldName = "TasksList", Message = "Task list shoud not be empty" }); } }
private void ValidateUniqueness(PluginProfileDto pluginProfile, PluginProfileErrorCollection errors) { if ( ProfileCollection.Any( x => string.Equals(x.Name.Value, pluginProfile.Name, StringComparison.InvariantCultureIgnoreCase))) { errors.Add(new PluginProfileError {FieldName = "Name", Message = "Profile name should be unique for plugin"}); } }
protected void ValidateNameNotEmpty(PluginProfileErrorCollection errors) { if (string.IsNullOrEmpty(Name)) errors.Add(new PluginProfileError { FieldName = NameField, Message = "Mashup name should be specified" }); }
private void ValidateUserMapping(PluginProfileErrorCollection errors) { if (UserMapping.Select(x => x.Key.ToLower()).Distinct().Count() != UserMapping.Count) { errors.Add(new PluginProfileError { FieldName = "user-mapping", Message = "Can't map a TFS user to TargetProcess user twice." }); } }
private void ValidateLogin(PluginProfileErrorCollection errors) { if (Login.IsNullOrWhitespace()) { errors.Add(new PluginProfileError { FieldName = "Login", Message = "Login should not be empty" }); } }
protected void ValidateNameContainsOnlyValidChars(PluginProfileErrorCollection errors) { if (!ProfileDtoValidator.IsValid(Name)) errors.Add(new PluginProfileError { FieldName = NameField, Message = "You can only use letters, numbers, space and underscore symbol in Mashup name" }); }
private bool StartRevisionShouldBeNumber(PluginProfileErrorCollection errors) { int result; if (!int.TryParse(StartRevision, out result)) { errors.Add(new PluginProfileError{FieldName = StartRevisionField, Message = "Start Revision should be a number."}); return false; } return true; }
private static PluginProfileErrorCollection ValidateProfileForSeleniumUrl(PluginProfileDto profileDto) { var errors = new PluginProfileErrorCollection(); if (string.IsNullOrEmpty(profileDto.Name) || string.IsNullOrEmpty(profileDto.Name.Trim())) { errors.Add(new PluginProfileError { FieldName = "Name", Message = "Profile name should not be empty" }); } ((TestRunImportPluginProfile)profileDto.Settings).ValidateSeleniumUrlData(errors); return errors; }
private void ValidateRolesMapping(PluginProfileErrorCollection errors) { if (RolesMapping.Any(x => x.Value == null || string.IsNullOrEmpty(x.Value.Name))) { errors.Add(new PluginProfileError { FieldName = RolesMappingField, Message = "All Bugzilla roles should be mapped to TP roles" }); } }
private bool StartRevisionShouldNotBeEmpty(PluginProfileErrorCollection errors) { if (!RevisionSpecified) { errors.Add(new PluginProfileError{FieldName = StartRevisionField, Message = "Start Revision should not be empty."}); return false; } return true; }
private bool StartRevisionShouldBeValidDate(PluginProfileErrorCollection errors) { DateTime result; if (!DateTime.TryParse(StartRevision, CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.AdjustToUniversal, out result)) { errors.Add(new PluginProfileError {FieldName = StartRevisionField, Message = string.Format("Start Revision Date should be specified in mm/dd/yyyy format")}); return false; } return true; }
private bool StartRevisionShouldBeNonNegative(PluginProfileErrorCollection errors) { int revisionNumber = int.Parse(StartRevision); if (revisionNumber < 0) { errors.Add(new PluginProfileError { FieldName = StartRevisionField, Message = "Start Revision cannot be less than zero." }); return false; } return true; }
protected void ValidateNameContainsOnlyValidChars(PluginProfileErrorCollection errors) { if (!ProfileDtoValidator.IsValid(Name)) { errors.Add(new PluginProfileError { FieldName = NameField, Message = "You can only use letters, numbers, space and underscore symbol in Mashup name" }); } }
private void ValidateNameHasValidCharacters(PluginProfileErrorCollection errors) { if (!IsValid(_dto.Name)) { errors.Add(new PluginProfileError { FieldName = "Name", Message = "You can only use letters, numbers, space and underscore symbol in Profile Name" }); } }
private void ValidateUniqueness(PluginProfileDto pluginProfile, PluginProfileErrorCollection errors) { if ( ProfileCollection.Any( x => string.Equals(x.Name.Value, pluginProfile.Name, StringComparison.InvariantCultureIgnoreCase))) { errors.Add(new PluginProfileError { FieldName = "Name", Message = "Profile name should be unique for plugin" }); } }
private void ValidateRules(PluginProfileErrorCollection errors) { if (Rules.IsNullOrWhitespace()) { errors.Add(new PluginProfileError { FieldName = "Rules", Message = "Rules should not be empty" }); } else { ValidateRulesFormat(errors); } }
private void ValidateRulesFormat(PluginProfileErrorCollection errors) { var parser = ObjectFactory.GetInstance<RuleParser>(); var parsed = parser.Parse(this); var stringRules = RuleParser.GetRuleLines(this); if(parsed.Count() != stringRules.Count()) { errors.Add(new PluginProfileError { FieldName = "Rules", Message = "Invalid rules format" }); } }
protected void ValidateNameNotEmpty(PluginProfileErrorCollection errors) { if (string.IsNullOrEmpty(Name)) { errors.Add(new PluginProfileError { FieldName = NameField, Message = "Mashup name should be specified" }); } }
private bool StartRevisionShouldNotExceedTheMax(PluginProfileErrorCollection errors) { DateTime result = DateTime.Parse(StartRevision, CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.AdjustToUniversal); if (result > GitRevisionId.UtcTimeMax) { errors.Add(new PluginProfileError {FieldName = StartRevisionField, Message = string.Format("Start Revision Date should be not behind {0}", GitRevisionId.UtcTimeMax.ToShortDateString())}); return false; } return true; }
protected override void ExecuteConcreate(PluginProfileErrorCollection errors) { try { var url = new BugzillaUrl(ConnectionSettings); WebClient webClient = new TpWebClient(errors) {Encoding = Encoding.UTF8}; webClient.DownloadString(url.Url); } catch (WebException webException) { if (webException.Status != WebExceptionStatus.TrustFailure) { errors.Add(new PluginProfileError { FieldName = BugzillaProfile.UrlField, Message = webException.Message, AdditionalInfo = ValidationErrorType.BugzillaNotFound.ToString() }); } } catch (Exception exception) { errors.Add(new PluginProfileError {FieldName = BugzillaProfile.UrlField, Message = exception.Message, AdditionalInfo = ValidationErrorType.BugzillaNotFound.ToString()}); } }
protected void ValidateNameNotEmpty(PluginProfileErrorCollection errors) { if (string.IsNullOrWhiteSpace(Name)) { errors.Add(new PluginProfileError { FieldName = NameField, Message = "Mashup name cannot be empty or consist of whitespace characters only" }); } }
public bugzilla_properties CheckConnection(BugzillaProfile profile) { var errors = new PluginProfileErrorCollection(); try { var validators = new Queue<Validator>(); var connectionValidator = new ConnectionValidator(profile); validators.Enqueue(connectionValidator); var scriptValidator = new ScriptValidator(profile); validators.Enqueue(scriptValidator); var responseValidator = new ResponseValidator(profile, scriptValidator); validators.Enqueue(responseValidator); var deserializeValidator = new DeserializeValidator(profile, responseValidator); validators.Enqueue(deserializeValidator); var settingsValidator = new SettingsValidator(profile, deserializeValidator); validators.Enqueue(settingsValidator); var savedQueryValidator = new SavedQueryValidator(profile); validators.Enqueue(savedQueryValidator); while (validators.Count > 0) { var validator = validators.Dequeue(); validator.Execute(errors); } if (errors.Any()) { throw new BugzillaPluginProfileException(profile, errors); } return deserializeValidator.Data; } catch (BugzillaPluginProfileException) { throw; } catch (Exception ex) { errors.Add(new PluginProfileError { FieldName = BugzillaProfile.ProfileField, Message = $"The connection with {profile} is failed. {ex.Message}" }); throw new BugzillaPluginProfileException(profile, errors); } }
public void ValidateStartWorkItem(PluginProfileErrorCollection errors) { Int32 startWorkItem; if (!Int32.TryParse(StartWorkItem, out startWorkItem) || startWorkItem < 1) { errors.Add(new PluginProfileError { FieldName = StartWorkItemField, Message = string.Format("Specify a start workitem number in the range of 1 - 2147483647"), Status = PluginProfileErrorStatus.WrongRevisionNumberError }); } }
private static PluginProfileErrorCollection ValidateProfileForMapping(PluginProfileDto profileDto) { var errors = new PluginProfileErrorCollection(); if (((TestRunImportPluginProfile)profileDto.Settings).PostResultsToRemoteUrl) { errors.Add(new PluginProfileError { FieldName = "Mapping", Message = "Check mapping is not available when results are posted to the remote Url" }); } else { ObjectFactory.GetInstance<IMappingProfileValidator>().ValidateProfileForMapping( ((TestRunImportPluginProfile) profileDto.Settings), errors); } return errors; }
private bool StartRevisionShouldBeNotLessThanMin(PluginProfileErrorCollection errors) { DateTime result = DateTime.Parse(StartRevision, CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.AdjustToUniversal); if (result < MercurialRevisionId.UtcTimeMin) { errors.Add(new PluginProfileError { FieldName = StartRevisionField, Message = string.Format("Start Revision Date should be not before {0}", MercurialRevisionId.UtcTimeMin.ToShortDateString()) }); return false; } return true; }
private static void CheckVersions(bugzilla_properties bugzillaProperties, PluginProfileErrorCollection errors) { if (!ScriptVersionIsValid(bugzillaProperties.script_version)) { errors.Add( new PluginProfileError { Message = string.Format( TP2_CGI_IS_NOT_SUPPORTED_BY_THIS_PLUGIN, string.IsNullOrEmpty(bugzillaProperties.script_version) ? "undefined" : bugzillaProperties.script_version), AdditionalInfo = ValidationErrorType.InvalidTpCgiVersion.ToString() }); } if (!errors.Any() && !BugzillaVersionIsSupported(bugzillaProperties.version)) { errors.Add(new PluginProfileError { Message = string.Format( BUGZILLA_VERSION_IS_NOT_SUPPORTED_BY_PLUGIN, bugzillaProperties.version), AdditionalInfo = ValidationErrorType.InvalidBugzillaVersion.ToString() }); } if (!errors.Any() && !ScriptSupportsProvidedBugzillaVersion(bugzillaProperties.version, bugzillaProperties.supported_bugzilla_version)) { errors.Add(new PluginProfileError { Message = string.Format( BUGZILLA_VERSION_IS_NOT_SUPPORTED_BY_TP2_CGI, bugzillaProperties.version), AdditionalInfo = ValidationErrorType.InvalidTpCgiVersion.ToString() }); } }