/// <summary> /// Initializes a new instance of the <see cref="ResolverBinaryRepository"/> class with resolver settings. /// </summary> /// <param name="settings">The resolver settings.</param> public ResolverBinaryRepository(ISettings <ResolverValidSettings> settings) { ResolverType = "Resolver_BinaryRepository"; Logger.Instance().Log(TraceLevel.Info, "Initializing resolver {0} ...", ResolverType); if (settings == null) { throw new InvalidProviderConfigurationException(); } if (string.IsNullOrEmpty(settings.GetSetting(ResolverValidSettings.BinaryTeamProjectCollectionUrl))) { throw new InvalidProviderConfigurationException(string.Format("Team project collection was not specified")); } if (string.IsNullOrEmpty(settings.GetSetting(ResolverValidSettings.BinaryRepositoryTeamProject))) { throw new InvalidProviderConfigurationException(string.Format("No repository team project was specified")); } if (string.IsNullOrEmpty(settings.GetSetting(ResolverValidSettings.DependencyDefinitionFileNameList))) { throw new InvalidProviderConfigurationException(string.Format("No dependency definition file list was specified")); } ResolverSettings = settings; ValidDependencyDefinitionFileNames = settings.GetSetting(ResolverValidSettings.DependencyDefinitionFileNameList).Split(new[] { ';' }).ToList(); ComponentTargetsName = ValidDependencyDefinitionFileNames.First(); PathPrefix = VersionControlPath.RootFolder + settings.GetSetting(ResolverValidSettings.BinaryRepositoryTeamProject); var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(ResolverSettings.GetSetting(ResolverValidSettings.BinaryTeamProjectCollectionUrl))); tpc.EnsureAuthenticated(); VersionControlServer = tpc.GetService <VersionControlServer>(); if (VersionControlServer == null) { Logger.Instance().Log(TraceLevel.Error, "{0}: Could not get VersionControlServer service for {1}", ResolverType, ResolverSettings.GetSetting(ResolverValidSettings.BinaryTeamProjectCollectionUrl)); throw new InvalidProviderConfigurationException(string.Format("Could not get VersionControlServer service for {0} in {1}", ResolverSettings.GetSetting(ResolverValidSettings.BinaryTeamProjectCollectionUrl), ResolverType)); } if (!VersionControlServer.ServerItemExists(PathPrefix, VersionSpec.Latest, DeletedState.NonDeleted, ItemType.Folder)) { Logger.Instance().Log(TraceLevel.Error, "{0}: Source control folder for binary repository {1} does not exist", ResolverType, ResolverSettings.GetSetting(ResolverValidSettings.BinaryRepositoryTeamProject)); throw new InvalidProviderConfigurationException(string.Format("Could not find binary repository {0} in version control", ResolverSettings.GetSetting(ResolverValidSettings.BinaryRepositoryTeamProject))); } Logger.Instance().Log(TraceLevel.Info, "Resolver {0} successfully initialized", ResolverType); }
/// <summary> /// Initializes a new instance of the <see cref="ResolverSourceControl"/> class resolver type and resolver settings. /// </summary> /// <param name="settings"> /// The resolver settings. /// </param> /// <param name="resolverType"> /// The specific source control resolver type. /// </param> public ResolverSourceControl(ISettings <ResolverValidSettings> settings, string resolverType) { if (string.IsNullOrEmpty(resolverType)) { throw new ArgumentNullException("resolverType", "No resolver type was supplied!"); } ResolverType = resolverType; Logger.Instance().Log(TraceLevel.Info, "Initializing resolver {0} ...", ResolverType); if (settings == null) { throw new ArgumentNullException("settings", "No resolver settings were supplied"); } if (string.IsNullOrEmpty(settings.GetSetting(ResolverValidSettings.TeamProjectCollectionUrl))) { throw new InvalidProviderConfigurationException("No team project collection url was supplied!"); } if (string.IsNullOrEmpty(settings.GetSetting(ResolverValidSettings.DependencyDefinitionFileNameList))) { throw new InvalidProviderConfigurationException(string.Format("No dependency definition file list was specified")); } ValidDependencyDefinitionFileNames = settings.GetSetting(ResolverValidSettings.DependencyDefinitionFileNameList).Split(new[] { ';' }).ToList(); ComponentTargetsName = ValidDependencyDefinitionFileNames.First(); ResolverSettings = settings; var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(ResolverSettings.GetSetting(ResolverValidSettings.TeamProjectCollectionUrl))); tpc.EnsureAuthenticated(); VersionControlServer = tpc.GetService <VersionControlServer>(); if (VersionControlServer == null) { Logger.Instance().Log(TraceLevel.Error, "{0}: Could not get VersionControlServer service for {1}", ResolverType, ResolverSettings.GetSetting(ResolverValidSettings.TeamProjectCollectionUrl)); throw new InvalidProviderConfigurationException(string.Format("Could not get VersionControlServer service for {0} in {1}", ResolverSettings.GetSetting(ResolverValidSettings.TeamProjectCollectionUrl), ResolverType)); } Logger.Instance().Log(TraceLevel.Info, "Resolver {0} successfully initialized", ResolverType); }
/// <summary> /// Initializes a new instance of the <see cref="ResolverSubversionControl"/> class resolver type and resolver settings. /// </summary> /// <param name="settings"> /// The resolver settings. /// </param> /// <param name="resolverType"> /// The specific subversion resolver type. /// </param> public ResolverSubversion(ISettings <ResolverValidSettings> settings) { ResolverType = "Resolver_Subversion"; Logger.Instance().Log(TraceLevel.Info, "Initializing resolver {0} ...", ResolverType); if (settings == null) { throw new ArgumentNullException("settings", "No resolver settings were supplied"); } var subversionUrl = settings.GetSetting(ResolverValidSettings.SubversionUrl); if (string.IsNullOrEmpty(subversionUrl)) { throw new InvalidProviderConfigurationException(string.Format("Subversion url was not supplied")); } try { if (!ProviderSubversion.Instance.ItemExists(subversionUrl)) { Logger.Instance().Log(TraceLevel.Error, "{0}: Folder not exists in Subversion {1}", ResolverType, settings.GetSetting(ResolverValidSettings.SubversionUrl)); throw new InvalidProviderConfigurationException(string.Format("Could not connect to Subversion {0}", settings.GetSetting(ResolverValidSettings.SubversionUrl))); } } catch (SvnAuthenticationException) { throw new SvnAuthenticationException(); } if (string.IsNullOrEmpty(settings.GetSetting(ResolverValidSettings.DependencyDefinitionFileNameList))) { throw new InvalidProviderConfigurationException(string.Format("No dependency definition file list was specified")); } ResolverSettings = settings; ValidDependencyDefinitionFileNames = settings.GetSetting(ResolverValidSettings.DependencyDefinitionFileNameList).Split(new[] { ';' }).ToList(); ComponentTargetsName = ValidDependencyDefinitionFileNames.First(); Logger.Instance().Log(TraceLevel.Info, "Resolver {0} successfully initialized", ResolverType); }