public string Translate(Guid srcMigrationSourceId, string srcServerPath) { IServerPathTranslationService srcTranslationService = LookupService(srcMigrationSourceId); string canonicalPath = srcTranslationService.TranslateToCanonicalPathCaseSensitive(srcServerPath); if (!m_pathValidator.IsSyntaxCorrect(canonicalPath)) { throw new InvalidServerPathException(string.Format( MigrationToolkitResources.VCPathTranslationErrVCPathTranslationError_InvalidCanonicalPath, canonicalPath)); } string canonicalFilterPath; canonicalPath = ApplyFilterMapping(srcMigrationSourceId, canonicalPath, out canonicalFilterPath); foreach (Guid sourceId in m_adapterPathTranslationServices.Keys) { if (!sourceId.Equals(srcMigrationSourceId)) { IServerPathTranslationService destTranslationService = LookupService(sourceId); return(destTranslationService.TranslateFromCanonicalPath(canonicalPath, canonicalFilterPath)); } } throw new ServerPathTranslationException( string.Format( MigrationToolkitResources.Culture, MigrationToolkitResources.VCPathTranslationError_CannotFindFilterString, srcServerPath)); }
/// <summary> /// Register an analysis provider with the analysis engine, /// 1. Intialize analysis service container and services. /// 2. Call analysis provider to register supported change actions. /// </summary> /// <param name="sourceId"></param> /// <param name="analysisProvider"></param> internal void RegisterAnalysisProvider( Guid sourceId, Session sessionConfig, IAnalysisProvider analysisProvider, IProvider adapter) { ServiceContainer serviceContainer; Debug.Assert(m_serviceContainers.ContainsKey(sourceId), string.Format(MigrationToolkitResources.UnknownSourceId, sourceId)); if (!m_serviceContainers.TryGetValue(sourceId, out serviceContainer)) { throw new MigrationException(string.Format( MigrationToolkitResources.Culture, MigrationToolkitResources.UnknownSourceId, sourceId)); } m_serviceContainers[sourceId].AddService(typeof(IAnalysisProvider), analysisProvider); m_analysisProviders.Add(sourceId, analysisProvider); // Call analysis provider to initialize basic services analysisProvider.InitializeServices(m_serviceContainers[sourceId]); // Call analysis provider to register supported content types ContentTypeRegistrationService contentTypeRegService = m_serviceContainers[sourceId].GetService(typeof(ContentTypeRegistrationService)) as ContentTypeRegistrationService; Debug.Assert(null != contentTypeRegService, "contentTypeRegService == NULL"); analysisProvider.RegisterSupportedContentTypes(contentTypeRegService); // Call analysis provider to register supported change actions ChangeActionRegistrationService changeActionRegistrationService = m_serviceContainers[sourceId].GetService(typeof(ChangeActionRegistrationService)) as ChangeActionRegistrationService; Debug.Assert(null != changeActionRegistrationService, "changeActionRegistrationService == NULL"); analysisProvider.RegisterSupportedChangeActions(changeActionRegistrationService); // Call analysis provider to register supported conflict types ConflictManager conflictManagementService = m_serviceContainers[sourceId].GetService(typeof(ConflictManager)) as ConflictManager; Debug.Assert(null != conflictManagementService, "conflictManager == NULL"); analysisProvider.RegisterConflictTypes(conflictManagementService); IServerPathTranslationService serverPathTranslationService = adapter.GetService(typeof(IServerPathTranslationService)) as IServerPathTranslationService; if (serverPathTranslationService != null) { m_serviceContainers[sourceId].AddService(typeof(IServerPathTranslationService), serverPathTranslationService); } foreach (AnalysisAddin analysisAddin in m_addinManagementService.GetMigrationSourceAnalysisAddins(sourceId)) { Debug.Assert(m_serviceContainers.ContainsKey(sourceId), "No ServiceContainer found for MigrationSource with Id: " + sourceId); AnalysisContext analysisContext = new AnalysisContext(m_serviceContainers[sourceId]); m_analysisContextsByMigrationSource.Add(sourceId, analysisContext); // Just need to create one AnalysisContext that can be shared by all of the Addins for a migration source since the contents are read-only // to the Addin break; } }
/// <summary> /// Gets the service object of the specified type. /// </summary> /// <param name="serviceType">An object that specifies the type of service object to get.</param> /// <returns> /// A service object of type <paramref name="serviceType"/>. /// -or- /// null if there is no service object of type <paramref name="serviceType"/>. /// </returns> object IServiceProvider.GetService(Type serviceType) { TraceManager.TraceInformation("WSSVC:Adapter:GetService - {0}", serviceType); if (serviceType == typeof(IAnalysisProvider)) { if (analysisProvider == null) { analysisProvider = new SharePointVCAnalysisProvider(); } return(analysisProvider); } if (serviceType == typeof(IMigrationProvider)) { if (migrationProvider == null) { migrationProvider = new SharePointVCMigrationProvider(); } return(migrationProvider); } if (serviceType == typeof(IServerPathTranslationService)) { if (transalationProvider == null) { transalationProvider = new SharePointVCAdapterTranslation(); } return(transalationProvider); } return(null); }
object IServiceProvider.GetService(Type serviceType) { TraceManager.TraceInformation("POC:Adapter:GetService - {0}", serviceType.ToString()); if (serviceType == typeof(IAnalysisProvider)) { if (m_analysisProvider == null) { m_analysisProvider = new PocVCAnalysisProvider(); } return(m_analysisProvider); } else if (serviceType == typeof(IMigrationProvider)) { if (m_migrationProvider == null) { m_migrationProvider = new PocVCMigrationProvider(); } return(m_migrationProvider); } else if (serviceType == typeof(IServerPathTranslationService)) { if (m_serverPathTranslationProvider == null) { m_serverPathTranslationProvider = new PoCVCAdapterTranslation(); } return(m_serverPathTranslationProvider); } return(new ArgumentException("Invalid Type :" + serviceType.Name)); }
/// <summary> /// Return a service based on serviceType. /// </summary> /// <param name="serviceType"></param> /// <returns></returns> public object GetService(Type serviceType) { if (serviceType == typeof(IAnalysisProvider)) { if (m_analysisProvider == null) { m_analysisProvider = new TfsFileSystemAnalysisProvider(); } return(m_analysisProvider); } else if (serviceType == typeof(IServerPathTranslationService)) { if (m_serverPathTranslationProvider == null) { m_serverPathTranslationProvider = new TfsFileSystemTranslationService(); } return(m_serverPathTranslationProvider); } else if (serviceType == typeof(IMigrationProvider)) { if (m_migrationProvider == null) { m_migrationProvider = new TfsFileSystemMigrationProvider(); } return(m_migrationProvider); } else if (serviceType == typeof(IVCDiffProvider)) { if (m_diffProvider == null) { m_diffProvider = new TfsFileSystemDiffProvider(); } return(m_diffProvider); } else if (serviceType == typeof(ISyncMonitorProvider)) { if (m_syncMonitorProvider == null) { m_syncMonitorProvider = new TfsFileSystemSyncMonitorProvider(); } return(m_syncMonitorProvider); } else if (serviceType == typeof(IMigrationItemSerializer)) { if (m_migrationItemSerializer == null) { m_migrationItemSerializer = new TfsFileSystemMigrationItemSerializer(); } return(m_migrationItemSerializer); } return(null); }
public VCServerPathTranslationService( Guid leftMigrationSourceId, IServerPathTranslationService leftPathTranslationService, Guid rightMigrationSourceId, IServerPathTranslationService rightPathTranslationService, Collection <FilterPair> filterStrings) { m_canonicalFilterStrings = new Dictionary <Guid, Dictionary <string, string> >(); m_pathValidator = new CanonicalServerPathValidator(m_canonicalFilterStrings); m_canonicalFilterStringsCloakedOnly = new Dictionary <Guid, List <string> >(); m_adapterPathTranslationServices.Add(leftMigrationSourceId, leftPathTranslationService); m_adapterPathTranslationServices.Add(rightMigrationSourceId, rightPathTranslationService); TranslateFilterStringPairs(filterStrings, leftMigrationSourceId, rightMigrationSourceId); }
public object GetService(Type serviceType) { if (serviceType == typeof(IAnalysisProvider)) { if (m_analysisProvider == null) { m_analysisProvider = new TfsVCAnalysisProvider(); } return(m_analysisProvider); } else if (serviceType == typeof(IMigrationProvider)) { if (m_migrationProvider == null) { m_migrationProvider = new TfsVCMigrationProvider(); } return(m_migrationProvider); } else if (serviceType == typeof(IVCDiffProvider)) { if (m_vcDiffProvider == null) { m_vcDiffProvider = new TfsVCDiffProvider(); } return(m_vcDiffProvider); } else if (serviceType == typeof(IServerPathTranslationService)) { if (m_serverPathTranslationProvider == null) { m_serverPathTranslationProvider = new TFSVCServerPathTranslationService(); } return(m_serverPathTranslationProvider); } else if (serviceType == typeof(ISyncMonitorProvider)) { if (m_syncMonitorProvider == null) { m_syncMonitorProvider = new TfsVCSyncMonitorProvider(); } return(m_syncMonitorProvider); } return(null); }
/// <summary> /// Return a service based on serviceType. /// </summary> /// <param name="serviceType"></param> /// <returns></returns> public object GetService(Type serviceType) { if (serviceType == typeof(IAnalysisProvider)) { if (m_analysisProvider == null) { m_analysisProvider = new ClearCaseSelectedHistoryAnalysisProvider(true); } return(m_analysisProvider); } else if (serviceType == typeof(IServerPathTranslationService)) { if (m_serverPathTranslationProvider == null) { m_serverPathTranslationProvider = new CCTranslationService(); } return(m_serverPathTranslationProvider); } else if (serviceType == typeof(IMigrationProvider)) { if (m_migrationProvider == null) { m_migrationProvider = new ClearCaseMigrationProvider(new TfsFileSystemMigrationItemSerializer(), "HWMLastSyncedTfsChangeset"); } return(m_migrationProvider); } else if (serviceType == typeof(IVCDiffProvider)) { if (m_diffProvider == null) { m_diffProvider = new ClearCaseDiffProvider(); } return(m_diffProvider); } else if (serviceType == typeof(ISyncMonitorProvider)) { if (m_syncMonitorProvider == null) { m_syncMonitorProvider = (ISyncMonitorProvider)m_analysisProvider.GetService(typeof(ISyncMonitorProvider)); } return(m_syncMonitorProvider); } return(null); }
/// <summary> /// Return a service based on serviceType. /// </summary> /// <param name="serviceType"></param> /// <returns></returns> public object GetService(Type serviceType) { if (serviceType == typeof(IAnalysisProvider)) { if (m_analysisProvider == null) { m_analysisProvider = new ClearCaseAnalysisProvider(); } return(m_analysisProvider); } else if (serviceType == typeof(IServerPathTranslationService)) { if (m_serverPathTranslationProvider == null) { m_serverPathTranslationProvider = new CCTranslationService(); } return(m_serverPathTranslationProvider); } else if (serviceType == typeof(IMigrationProvider)) { if (m_migrationProvider == null) { m_migrationProvider = new ClearCaseMigrationProvider(); } return(m_migrationProvider); } else if (serviceType == typeof(IVCDiffProvider)) { if (m_diffProvider == null) { m_diffProvider = new ClearCaseDiffProvider(); } return(m_diffProvider); } else if (serviceType == typeof(ISyncMonitorProvider)) { if (m_syncMonitorProvider == null) { m_syncMonitorProvider = new ClearCaseSyncMonitorProvider(); } return(m_syncMonitorProvider); } return(null); }
internal VCTranslationService( Session session, Guid leftMigrationSourceId, Guid rightMigrationSourceId, IProvider leftProvider, IProvider rightProvider, UserIdentityLookupService userIdLookupService) : base(session, userIdLookupService) { IServerPathTranslationService leftPathTranslationService = leftProvider.GetService(typeof(IServerPathTranslationService)) as IServerPathTranslationService; if (null == leftPathTranslationService) { TraceManager.TraceWarning(MigrationToolkitResources.ErrorMissingVCPathTranslationService, leftMigrationSourceId.ToString()); // default to UnixStyle Server Path translation service leftPathTranslationService = new UnixStyleServerPathTranslationService(); } leftPathTranslationService.Initialize(session.Filters[leftMigrationSourceId]); IServerPathTranslationService rightPathTranslationService = rightProvider.GetService(typeof(IServerPathTranslationService)) as IServerPathTranslationService; if (null == rightPathTranslationService) { TraceManager.TraceWarning(MigrationToolkitResources.ErrorMissingVCPathTranslationService, rightMigrationSourceId.ToString()); // default to UnixStyle Server Path translation service rightPathTranslationService = new UnixStyleServerPathTranslationService(); } rightPathTranslationService.Initialize(session.Filters[rightMigrationSourceId]); m_serverPathTranslationService = new VCServerPathTranslationService(leftMigrationSourceId, leftPathTranslationService, rightMigrationSourceId, rightPathTranslationService, m_session.Filters.FilterPair); m_migratinSourcePair.Add(leftMigrationSourceId, rightMigrationSourceId); m_migratinSourcePair.Add(rightMigrationSourceId, leftMigrationSourceId); }
public override void PreAnalysis(AnalysisContext analysisContext) { m_configurationService = analysisContext.TookitServiceContainer.GetService(typeof(ConfigurationService)) as ConfigurationService; if (m_configurationService == null) { throw new ArgumentNullException("ConfigurationService"); } m_serverPathTranslationService = (IServerPathTranslationService)((analysisContext.TookitServiceContainer.GetService(typeof(IServerPathTranslationService)) as IServerPathTranslationService)); if (m_serverPathTranslationService == null) { throw new ArgumentNullException("IServerPathTranslationService"); } m_vcTranslationService = (VCTranslationService)((analysisContext.TookitServiceContainer.GetService(typeof(ITranslationService)) as ITranslationService)); if (m_vcTranslationService == null) { throw new ArgumentNullException("ITranslationService"); } m_sourceId = new Guid(m_configurationService.MigrationSource.InternalUniqueId); // Get the configured output file path here (or use default) and make sure we can open it for writing Dictionary <string, string> addinCustomSettings = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); addinCustomSettings.Add(c_symbolLinkOutputFilePathKey, c_defaultSymbolLinkOutputFilePath); AddinCustomSettingsHelper.GetAddinCustomSettings(m_configurationService, ReferenceNameString, addinCustomSettings); m_symbolLinkOutputFilePath = addinCustomSettings[c_symbolLinkOutputFilePathKey]; try { using (StreamWriter streamWriter = new StreamWriter(m_symbolLinkOutputFilePath, false)) { } } catch (Exception e) { throw new MigrationException(string.Format(CultureInfo.InvariantCulture, ClearCaseSymbolicLinkMonitorAnalysisAddinResources.UnableToOpenOutputFile, m_symbolLinkOutputFilePath, e.Message)); } }
private void TranslateFilterStringPairs( Collection <FilterPair> filterStrings, Guid leftMigrationSourceId, Guid rightMigrationSourceId) { m_canonicalFilterStringsCloakedOnly.Add(leftMigrationSourceId, new List <string>()); m_canonicalFilterStringsCloakedOnly.Add(rightMigrationSourceId, new List <string>()); IServerPathTranslationService leftPathTranslationService = LookupService(leftMigrationSourceId); IServerPathTranslationService rightPathTranslationService = LookupService(rightMigrationSourceId); foreach (FilterPair filterPair in filterStrings) { Debug.Assert(filterPair.FilterItem.Count == 2, "FilterPairs must have exactly two items"); string leftCanonicalFilter = null; string rightCanonicalFilter = null; for (int i = 0; i < 2; ++i) { FilterItem filterItem = filterPair.FilterItem[i]; string adapterSpecificFilterStr = filterItem.FilterString; Guid filterOwnerMigrationSourceId = new Guid(filterItem.MigrationSourceUniqueId); if (leftMigrationSourceId.Equals(filterOwnerMigrationSourceId)) { leftCanonicalFilter = leftPathTranslationService.TranslateToCanonicalPathCaseSensitive(adapterSpecificFilterStr); if (m_pathValidator.IsSyntaxCorrect(leftCanonicalFilter)) { leftCanonicalFilter = RemoveTailingDelimiter(leftCanonicalFilter); } if (filterPair.Neglect) { m_canonicalFilterStringsCloakedOnly[leftMigrationSourceId].Add(leftCanonicalFilter); } } else if (rightMigrationSourceId.Equals(filterOwnerMigrationSourceId)) { rightCanonicalFilter = rightPathTranslationService.TranslateToCanonicalPathCaseSensitive(adapterSpecificFilterStr); if (m_pathValidator.IsSyntaxCorrect(rightCanonicalFilter)) { rightCanonicalFilter = RemoveTailingDelimiter(rightCanonicalFilter); } if (filterPair.Neglect) { m_canonicalFilterStringsCloakedOnly[rightMigrationSourceId].Add(rightCanonicalFilter); } } } if (!string.IsNullOrEmpty(leftCanonicalFilter) && !string.IsNullOrEmpty(rightCanonicalFilter)) { if (!m_canonicalFilterStrings.ContainsKey(leftMigrationSourceId)) { m_canonicalFilterStrings.Add(leftMigrationSourceId, new Dictionary <string, string>()); } if (!m_canonicalFilterStrings.ContainsKey(rightMigrationSourceId)) { m_canonicalFilterStrings.Add(rightMigrationSourceId, new Dictionary <string, string>()); } // there should be no 1:M filter mapping in the config if (!m_canonicalFilterStrings[leftMigrationSourceId].ContainsKey(leftCanonicalFilter) && !m_canonicalFilterStrings[rightMigrationSourceId].ContainsKey(rightCanonicalFilter)) { m_canonicalFilterStrings[leftMigrationSourceId].Add(leftCanonicalFilter, rightCanonicalFilter); m_canonicalFilterStrings[rightMigrationSourceId].Add(rightCanonicalFilter, leftCanonicalFilter); } } } }
public ChangeGroupLabel(ChangeGroup changeGroup, AnalysisContext analysisContext) { m_changeGroup = changeGroup; m_configurationService = analysisContext.TookitServiceContainer.GetService(typeof(ConfigurationService)) as ConfigurationService; if (m_configurationService == null) { throw new ArgumentNullException("ConfigurationService"); } m_serverPathTranslationService = analysisContext.TookitServiceContainer.GetService(typeof(IServerPathTranslationService)) as IServerPathTranslationService; if (m_serverPathTranslationService == null) { throw new ArgumentNullException("IServerPathTranslationService"); } HashSet <string> deletedItems = new HashSet <string>(); foreach (IMigrationAction action in changeGroup.Actions) { if (action.Action == WellKnownChangeActionId.Add || action.Action == WellKnownChangeActionId.Branch || action.Action == WellKnownChangeActionId.Edit || action.Action == WellKnownChangeActionId.Merge || action.Action == WellKnownChangeActionId.Rename || action.Action == WellKnownChangeActionId.Undelete) { if (!m_labelItems.ContainsKey(action.Path)) { m_labelItems.Add(action.Path, new ChangeGroupLabelItem(action)); } } // Also add label items for implicit changes to the parent folder for any items that were added, deleted, or renamed. // This occurs with ClearCase (and perhaps other servers) // TODO: Add CustomSetting to allow disabling this? if (action.Action == WellKnownChangeActionId.Add || action.Action == WellKnownChangeActionId.Delete || action.Action == WellKnownChangeActionId.Rename || action.Action == WellKnownChangeActionId.Undelete) { // Note: this depends on the fact that all ChangeAction Paths are in canonical form ('/' for separator) int lastSeparator = action.Path.LastIndexOf('/'); string parentPath = (lastSeparator == -1) ? @"/" : action.Path.Substring(0, lastSeparator); // Don't add more than one label item for the same parent folder if (!m_labelItems.ContainsKey(parentPath) && IsPathMapped(parentPath, analysisContext)) { m_labelItems.Add(parentPath, new ChangeGroupLabelItem(parentPath)); } } if (action.Action == WellKnownChangeActionId.Delete) { if (!deletedItems.Contains(action.Path)) { deletedItems.Add(action.Path); } } if (action.Action == WellKnownChangeActionId.Rename && !string.IsNullOrEmpty(action.FromPath)) { if (!deletedItems.Contains(action.FromPath)) { deletedItems.Add(action.FromPath); } } } // Remove any deleted items from the label items foreach (string deletedItem in deletedItems) { m_labelItems.Remove(deletedItem); } }