예제 #1
0
        /// <summary>
        /// Takes a corpus path, figures out the right adapter to use and then returns an adapter domain path.
        /// </summary>
        public string CorpusPathToAdapterPath(string corpusPath)
        {
            if (string.IsNullOrEmpty(corpusPath))
            {
                Logger.Error(nameof(CdmCorpusDefinition), (ResolveContext)this.Ctx, $"The corpus path is null or empty", nameof(CorpusPathToAdapterPath));
                return(null);
            }

            string result = "";
            // break the corpus path into namespace and ... path
            Tuple <string, string> pathTuple = SplitNamespacePath(corpusPath);
            string nameSpace = pathTuple.Item1;

            if (string.IsNullOrWhiteSpace(nameSpace))
            {
                nameSpace = this.DefaultNamespace;
            }

            // get the adapter registered for this namespace
            StorageAdapter namespaceAdapter = this.FetchAdapter(nameSpace);

            if (namespaceAdapter == null)
            {
                Logger.Error(nameof(CdmCorpusDefinition), (ResolveContext)this.Ctx, $"The namespace '{nameSpace}' has not been registered", nameof(CorpusPathToAdapterPath));
            }
            else
            {
                // ask the storage adapter to 'adapt' this path
                result = namespaceAdapter.CreateAdapterPath(pathTuple.Item2);
            }

            return(result);
        }
예제 #2
0
        /// <summary>
        /// Takes a corpus path, figures out the right adapter to use and then returns an adapter domain path.
        /// </summary>
        public string CorpusPathToAdapterPath(string corpusPath)
        {
            using (Logger.EnterScope(nameof(StorageManager), Ctx, nameof(CorpusPathToAdapterPath)))
            {
                if (string.IsNullOrEmpty(corpusPath))
                {
                    Logger.Error(this.Ctx, Tag, nameof(CorpusPathToAdapterPath), null, CdmLogCode.ErrStorageNullCorpusPath);
                    return(null);
                }

                string result = "";
                // break the corpus path into namespace and ... path
                Tuple <string, string> pathTuple = StorageUtils.SplitNamespacePath(corpusPath);
                if (pathTuple == null)
                {
                    Logger.Error(this.Ctx, Tag, nameof(CorpusPathToAdapterPath), null, CdmLogCode.ErrStorageNullCorpusPath);
                    return(null);
                }
                string nameSpace = pathTuple.Item1;
                if (string.IsNullOrWhiteSpace(nameSpace))
                {
                    nameSpace = this.DefaultNamespace;
                }

                // get the adapter registered for this namespace
                StorageAdapter namespaceAdapter = this.FetchAdapter(nameSpace);
                if (namespaceAdapter == null)
                {
                    Logger.Error(this.Ctx, Tag, nameof(CorpusPathToAdapterPath), null, CdmLogCode.ErrStorageNamespaceNotRegistered, nameSpace);
                }
                else
                {
                    // ask the storage adapter to 'adapt' this path
                    result = namespaceAdapter.CreateAdapterPath(pathTuple.Item2);
                }

                return(result);
            }
        }