private static string GetResponse(string args) { var profile = args.DeserializeProfile(); var settings = (ConnectionSettings) profile.Settings; var errors = new PluginProfileErrorCollection(); settings.ValidateConnection(errors); if (errors.Any()) { return errors.Serialize(); } CheckConnection(settings, errors); return errors.Any() ? errors.Serialize() : string.Empty; }
private static string GetResponse(string args) { var profile = args.DeserializeProfile(); var settings = (ConnectionSettings)profile.Settings; var errors = new PluginProfileErrorCollection(); settings.ValidateConnection(errors); if (errors.Any()) { return(errors.Serialize()); } CheckConnection(settings, errors); return(errors.Any() ? errors.Serialize() : string.Empty); }
public void Execute(PluginProfileErrorCollection errors) { if (errors.Any()) return; ExecuteConcreate(errors); }
protected override void OnCheckConnection(PluginProfileErrorCollection errors, GitPluginProfile settings) { settings.ValidateUri(errors); if (!errors.Any()) { _folder = GitRepositoryFolder.Create(settings.Uri); var nativeGit = NGit.Api.Git.Init().SetDirectory(_folder.GetAbsolutePath()).Call(); var transport = Transport.Open(nativeGit.GetRepository(), settings.Uri); try { transport.SetCredentialsProvider(new UsernamePasswordCredentialsProvider(settings.Login, settings.Password)); transport.OpenFetch(); } catch (EOFException ex) { transport.Close(); throw new InvalidOperationException("Unable to connect to repository. Run 'git fsck' in the repository to check for possible errors.", ex); } catch { transport.Close(); throw; } } }
public void Execute(PluginProfileErrorCollection errors) { if (errors.Any()) { return; } ExecuteConcreate(errors); }
protected override void OnCheckConnection(PluginProfileErrorCollection errors, SubversionPluginProfile settings) { settings.ValidateUri(errors); if (!errors.Any()) { base.OnCheckConnection(errors, settings); } }
public bugzilla_properties CheckConnection(BugzillaProfile profile) { var errors = new PluginProfileErrorCollection(); try { SetServerCertificateValidationCallback(profile); 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 = string.Format("The connection with {0} is failed. {1}", profile, ex.Message) }); throw new BugzillaPluginProfileException(profile, errors); } }
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 = string.Format("The connection with {0} is failed. {1}", profile, ex.Message) }); throw new BugzillaPluginProfileException(profile, errors); } }
protected override void OnCheckConnection(PluginProfileErrorCollection errors, MercurialPluginProfile settings) { settings.ValidateUri(errors); if (!errors.Any()) { var identifyCommand = new IdentifyCommand().WithPath(settings.Uri).WithTimeout(20); NonPersistentClient.Execute(identifyCommand); if (identifyCommand.RawExitCode != 0) { throw new Exception("Can't establish connection"); } } }
public PluginCommandResponseMessage Execute(string args, UserDTO user) { var errors = new PluginProfileErrorCollection(); var profile = args.DeserializeProfile(); var settings = (BugzillaProfile) profile.Settings; var properties = GetBugzillaProperties(settings, errors); return errors.Any() ? new PluginCommandResponseMessage {PluginCommandStatus = PluginCommandStatus.Fail, ResponseData = errors.Serialize()} : new PluginCommandResponseMessage {PluginCommandStatus = PluginCommandStatus.Succeed, ResponseData = properties.Serialize()}; }
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() }); } }
public PluginCommandResponseMessage Execute(string args) { var mashup = args.Deserialize <T>(); NormalizeMashup(mashup); PluginProfileErrorCollection errors = ExecuteOperation(mashup); return(new PluginCommandResponseMessage { PluginCommandStatus = errors.Any() ? PluginCommandStatus.Fail : PluginCommandStatus.Succeed, ResponseData = errors.Serialize() }); }
public PluginCommandResponseMessage Execute(string args) { var errors = new PluginProfileErrorCollection(); var profile = args.DeserializeProfile(); var settings = (BugzillaProfile)profile.Settings; var properties = GetBugzillaProperties(settings, errors); return(errors.Any() ? new PluginCommandResponseMessage { PluginCommandStatus = PluginCommandStatus.Fail, ResponseData = errors.Serialize() } : new PluginCommandResponseMessage { PluginCommandStatus = PluginCommandStatus.Succeed, ResponseData = properties.Serialize() }); }
protected void ValidateNameUniqueness(PluginProfileErrorCollection errors, MashupManagerProfile profile) { if (errors.Any()) return; var existsSuchName = profile != null && profile.MashupNames .Any( m => m.Equals(Name, StringComparison.InvariantCultureIgnoreCase)); if (existsSuchName) { errors.Add(new PluginProfileError { FieldName = NameField, Message = "Mashup with the same name already exists" }); } }
protected void ValidateNameUniqueness(PluginProfileErrorCollection errors, MashupManagerProfile profile) { if (errors.Any()) { return; } var existsSuchName = profile != null && profile.MashupNames .Any( m => m.Equals(Name, StringComparison.InvariantCultureIgnoreCase)); if (existsSuchName) { errors.Add(new PluginProfileError { FieldName = NameField, Message = "Mashup with the same name already exists" }); } }
public BugzillaProperties GetBugzillaProperties(BugzillaProfile profile, PluginProfileErrorCollection errors) { profile.ValidateCredentials(errors); if (!errors.Any()) { try { _logger.Info("Checking connection"); var bugzillaProperties = new BugzillaService().CheckConnection(profile); _logger.Info("Connection success"); return new BugzillaProperties(bugzillaProperties); } catch (BugzillaPluginProfileException e) { e.ErrorCollection.ForEach(errors.Add); _logger.WarnFormat("Connection failed: {0}", e); } } return null; }
public BugzillaProperties GetBugzillaProperties(BugzillaProfile profile, PluginProfileErrorCollection errors) { profile.ValidateCredentials(errors); if (!errors.Any()) { try { _logger.Info("Checking connection"); var bugzillaProperties = new BugzillaService().CheckConnection(profile); _logger.Info("Connection success"); return(new BugzillaProperties(bugzillaProperties)); } catch (BugzillaPluginProfileException e) { e.ErrorCollection.ForEach(errors.Add); _logger.WarnFormat("Connection failed: {0}", e); } } return(null); }
protected override void OnCheckConnection(PluginProfileErrorCollection errors, TfsPluginProfile settings) { settings.ValidateStartRevision(errors); settings.ValidateUri(errors); if (!errors.Any()) { TfsTeamProjectCollection collection = null; try { TfsConnectionParameters parameters = TfsConnectionHelper.GetTfsConnectionParameters(settings); switch (parameters.SegmentsCount) { case UriTfsProjectCollection: { collection = new TfsTeamProjectCollection(parameters.TfsCollectionUri, parameters.Credential); collection.EnsureAuthenticated(); collection.Connect(ConnectOptions.None); var vcs = collection.GetService <VersionControlServer>(); CheckChangeset(settings, vcs); break; } case UriTfsTeamProject: { collection = new TfsTeamProjectCollection(parameters.TfsCollectionUri, parameters.Credential); collection.EnsureAuthenticated(); collection.Connect(ConnectOptions.None); var vcs = collection.GetService <VersionControlServer>(); TeamProject teamProject = vcs.GetTeamProject(parameters.TeamProjectName); CheckChangeset(settings, vcs, teamProject); break; } default: errors.Add(new PluginProfileError { FieldName = "Uri", Message = "Could not connect to server." }); break; } } catch (TeamFoundationServerUnauthorizedException e) { errors.Add( new PluginProfileError { Status = PluginProfileErrorStatus.WrongCredentialsError, FieldName = "Login", Message = "Authorization failed.", AdditionalInfo = e.Message }); errors.Add( new PluginProfileError { Status = PluginProfileErrorStatus.WrongCredentialsError, FieldName = "Password", Message = "Authorization failed.", AdditionalInfo = e.Message }); } catch (ResourceAccessException e) { errors.Add(new PluginProfileError { AdditionalInfo = e.Message, FieldName = "Uri", Message = "Resource access denied", Status = PluginProfileErrorStatus.Error }); } catch (ChangesetNotFoundException e) { errors.Add(new PluginProfileError { AdditionalInfo = e.Message, FieldName = "StartRevision", Message = "There’s no such revision.", Status = PluginProfileErrorStatus.UnexistedRevisionWarning }); } catch (TeamFoundationServiceUnavailableException e) { errors.Add(new PluginProfileError { AdditionalInfo = e.Message, FieldName = "Uri", Message = "Could not connect to server.", }); } finally { if (collection != null) { collection.Dispose(); } } } }
public void CheckConnectionIsValid() { _errors.Any().Should(Be.False); }
public void ErrorShouldOccur(string fieldName, string errorMessage) { _errors.Any(x => x.FieldName == fieldName && x.Message == errorMessage).Should(Be.True); }