Example #1
0
        public void DefaultContenExistTwoFoundTest()
        {
            IContentStore contentStore = manager.GetContentStore(repositoryId);

            contentStore.Items.Add(new StringContentItem()
            {
                Id           = Guid.NewGuid(),
                DefinitionId = definitionId,
                Data         = "First"
            });
            contentStore.Items.Add(new StringContentItem()
            {
                Id           = Guid.NewGuid(),
                DefinitionId = definitionId,
                Data         = "Second"
            });
            contentStore.Save();

            // check GetContentString
            ContentEngine engine = new ContentEngine(repositoryName);

            Assert.AreEqual("First", engine.GetContentString(contentName));

            // check GetContentStrings
            var list = engine.GetContentStrings(contentName).ToList();

            Assert.AreEqual(2, list.Count);
            Assert.AreEqual("First", list[0]);
            Assert.AreEqual("Second", list[1]);
        }
Example #2
0
        public IActionResult Edit(Guid repositoryid, Guid contentid)
        {
            ICmsManager manager    = new CmsManager();
            IRepository repository = manager.GetRepositoryById(repositoryid);

            if (repository == null)
            {
                return(Redirect("/fcmsmanager/home"));
            }

            IContentStore contentStore = manager.GetContentStore(repositoryid);

            EditContentViewModel model = new EditContentViewModel();

            model.RepositoryName = repository.Name;
            model.Item           = contentStore.Items.Where(m => m.Id == contentid).FirstOrDefault();
            if (model.Item == null)
            {
                return(Redirect("/fcmsmanager/repository?d=" + contentid));
            }

            model.ContentDefinition = repository.ContentDefinitions.Where(m => m.DefinitionId == model.Item.DefinitionId).FirstOrDefault();
            model.RepositoryId      = repositoryid;

            return(View("Edit", model));
        }
Example #3
0
        public async Task <OpenApiResult> GetContentSummary(IOpenApiContext context, string slug, string contentId, string ifNoneMatch)
        {
            IContentStore contentStore = await this.contentStoreFactory.GetContentStoreForTenantAsync(context.CurrentTenantId).ConfigureAwait(false);

            ContentSummary result = await contentStore.GetContentSummaryAsync(contentId, slug).ConfigureAwait(false);

            string etag = EtagHelper.BuildEtag(nameof(ContentSummary), result.ETag);

            // If the etag in the result matches ifNoneMatch then we return 304 Not Modified
            if (EtagHelper.IsMatch(ifNoneMatch, etag))
            {
                return(this.NotModifiedResult());
            }

            HalDocument resultDocument = this.contentSummaryMapper.Map(result, new ResponseMappingContext {
                TenantId = context.CurrentTenantId
            });

            OpenApiResult response = this.OkResult(resultDocument);

            response.Results.Add(HeaderNames.ETag, etag);

            // Since content is immutable we can allow clients to cache it indefinitely.
            response.Results.Add(HeaderNames.CacheControl, Constants.CacheControlHeaderOptions.NeverExpire);

            return(response);
        }
Example #4
0
        public async Task <OpenApiResult> GetContentHistory(string tenantId, string slug, int?limit, string continuationToken, string ifNoneMatch)
        {
            IContentStore contentStore = await this.contentStoreFactory.GetContentStoreForTenantAsync(tenantId).ConfigureAwait(false);

            ContentSummaries result = await contentStore.GetContentSummariesAsync(slug, limit ?? 20, continuationToken).ConfigureAwait(false);

            string resultEtag = EtagHelper.BuildEtag(nameof(ContentSummary), result.Summaries.Select(x => x.ETag).ToArray());

            // If the etag in the result matches ifNoneMatch then we return 304 Not Modified
            if (EtagHelper.IsMatch(ifNoneMatch, resultEtag))
            {
                return(this.NotModifiedResult());
            }

            var mappingContext = new ContentSummariesResponseMappingContext
            {
                ContinuationToken = continuationToken,
                Limit             = limit,
                Slug     = slug,
                TenantId = tenantId,
            };

            HalDocument resultDocument = this.contentSummariesMapper.Map(result, mappingContext);

            OpenApiResult response = this.OkResult(resultDocument);

            response.Results.Add(HeaderNames.ETag, resultEtag);

            return(response);
        }
Example #5
0
        /// <summary>
        /// Copies the given content in the <see cref="WellKnownWorkflowId.ContentPublication"/> workflow.
        /// </summary>
        /// <param name="contentStore">The content store for which this is an extension.</param>
        /// <param name="targetSlug">The slug to which to move the content.</param>
        /// <param name="originalSlug">The slug from which the content is to be moved.</param>
        /// <param name="stateChangedBy">The identity that made the change.</param>
        /// <param name="targetState">The target state for the copy; the default is <see cref="ContentPublicationContentState.Draft"/>.</param>
        /// <returns>A <see cref="Task"/> which completes when the content is published.</returns>
        public static async Task <Content> CopyContentForPublicationAsync(this IContentStore contentStore, string targetSlug, string originalSlug, CmsIdentity stateChangedBy, string targetState = ContentPublicationContentState.Draft)
        {
            if (contentStore is null)
            {
                throw new ArgumentNullException(nameof(contentStore));
            }

            if (targetSlug is null)
            {
                throw new ArgumentNullException(nameof(targetSlug));
            }

            if (originalSlug is null)
            {
                throw new ArgumentNullException(nameof(originalSlug));
            }

            ContentState state = await contentStore.GetContentStateForWorkflowAsync(originalSlug, WellKnownWorkflowId.ContentPublication).ConfigureAwait(false);

            Content copiedContent = await contentStore.CopyContentAsync(targetSlug, state.ContentId, originalSlug).ConfigureAwait(false);

            await contentStore.SetContentWorkflowStateAsync(targetSlug, copiedContent.Id, WellKnownWorkflowId.ContentPublication, targetState, stateChangedBy).ConfigureAwait(false);

            return(copiedContent);
        }
Example #6
0
        public ColdStorage(IAbsFileSystem fileSystem, ColdStorageSettings coldStorageSettings, DistributedContentCopier distributedContentCopier)
        {
            _fileSystem = fileSystem;
            _copier     = distributedContentCopier;

            _rootPath = coldStorageSettings.GetAbsoulutePath();

            ConfigurationModel configurationModel
                = new ConfigurationModel(new ContentStoreConfiguration(new MaxSizeQuota(coldStorageSettings.CacheSizeQuotaString !)));

            ContentStoreSettings contentStoreSettings = FromColdStorageSettings(coldStorageSettings);

            _store = new FileSystemContentStore(fileSystem, SystemClock.Instance, _rootPath, configurationModel, null, contentStoreSettings, null);

            HashType hashType;

            if (!Enum.TryParse <HashType>(coldStorageSettings.ConsistentHashingHashType, true, out hashType))
            {
                hashType = HashType.SHA256;
            }
            _contentHasher = HashInfoLookup.GetContentHasher(hashType);

            _copiesQuantity    = coldStorageSettings.ConsistentHashingCopiesQuantity;
            _maxParallelPlaces = coldStorageSettings.MaxParallelPlaces;

            // Starts empty and is created during the first update
            _ring = new RingNode[0];
        }
 public async Task GivenIDraftTheContentWithSlug(string slug)
 {
     IContentStore store = ContentManagementCosmosContainerBindings.GetContentStore(this.featureContext);
     await store.MakeDraftContentAsync(
         SpecHelpers.ParseSpecValue <string>(this.scenarioContext, slug),
         new CmsIdentity("SomeId", "SomeName")).ConfigureAwait(false);
 }
        public async Task WhenIGetTheContentPublicationStateForSlugAndCallItAsync(string slug, string contentName)
        {
            IContentStore store   = ContentManagementCosmosContainerBindings.GetContentStore(this.featureContext);
            ContentState  content = await store.GetContentPublicationStateAsync(SpecHelpers.ParseSpecValue <string>(this.scenarioContext, slug)).ConfigureAwait(false);

            this.scenarioContext.Set(content, contentName);
        }
        /// <summary>
        /// Creates a copy of the given content at the new slug, with traceability back to the original content.
        /// </summary>
        /// <param name="contentStore">The content store for which this is an extension.</param>
        /// <param name="targetSlug">The target slug for the content.</param>
        /// <param name="originalContentId">The original ID of the content to copy.</param>
        /// <param name="originalSlug">The original slug of the content to copy.</param>
        /// <returns>A <see cref="Task{Content}"/> which completes when the content is moved.</returns>
        public static async Task <Content> CopyContentAsync(this IContentStore contentStore, string targetSlug, string originalContentId, string originalSlug)
        {
            if (contentStore is null)
            {
                throw new System.ArgumentNullException(nameof(contentStore));
            }

            if (originalSlug is null)
            {
                throw new System.ArgumentNullException(nameof(originalSlug));
            }

            if (string.IsNullOrEmpty(originalContentId))
            {
                throw new System.ArgumentException("message", nameof(originalContentId));
            }

            if (targetSlug is null)
            {
                throw new System.ArgumentNullException(nameof(targetSlug));
            }

            Content originalContent = await contentStore.GetContentAsync(originalContentId, originalSlug).ConfigureAwait(false);

            Content newContent = originalContent.Copy(true);

            newContent.Slug           = targetSlug;
            newContent.OriginalSource = new ContentReference(originalContent.Slug, originalContent.Id);

            return(await contentStore.StoreContentAsync(newContent).ConfigureAwait(false));
        }
        public static async Task CreateContentStateTestData(FeatureContext featureContext)
        {
            ITenantedContentStoreFactory contentStoreFactory = ContainerBindings.GetServiceProvider(featureContext).GetRequiredService <ITenantedContentStoreFactory>();
            IContentStore store = await contentStoreFactory.GetContentStoreForTenantAsync(featureContext.GetCurrentTenantId()).ConfigureAwait(false);

            for (int i = 0; i < 30; i++)
            {
                var state = new ContentState
                {
                    Id         = Guid.NewGuid().ToString(),
                    ContentId  = SpecHelpers.ParseSpecValue <string>(featureContext, $"{{Content{i}.Id}}"),
                    Slug       = SpecHelpers.ParseSpecValue <string>(featureContext, $"{{Content{i}.Slug}}"),
                    WorkflowId = "workflow1id",
                    ChangedBy  = new CmsIdentity(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()),
                };

                if (i < 4)
                {
                    state.StateName = "draft";
                }
                else if (i < 29)
                {
                    state.StateName = "published";
                }
                else
                {
                    state.StateName = "archived";
                }

                ContentState storedContentState = await store.SetContentWorkflowStateAsync(state.Slug, state.ContentId, state.WorkflowId, state.StateName, state.ChangedBy).ConfigureAwait(false);

                featureContext.Set(storedContentState, $"Content{i}-State");
            }
        }
        public async Task <OpenApiResult> GetWorkflowStateHistory(
            string tenantId,
            string workflowId,
            string stateName,
            string slug,
            int?limit,
            string continuationToken,
            string embed)
        {
            IContentStore contentStore = await this.contentStoreFactory.GetContentStoreForTenantAsync(tenantId).ConfigureAwait(false);

            ContentStates result = await contentStore.GetContentStatesForWorkflowAsync(slug, workflowId, stateName, limit ?? 20, continuationToken).ConfigureAwait(false);

            var mappingContext = new ContentStatesResponseMappingContext {
                TenantId = tenantId
            };

            if (embed == Constants.LinkRelations.ContentSummary)
            {
                mappingContext.ContentSummaries = await contentStore.GetContentSummariesForStatesAsync(result.States).ConfigureAwait(false);
            }

            HalDocument resultDocument = this.contentStatesMapper.Map(result, mappingContext);

            return(this.OkResult(resultDocument));
        }
        public static async Task CreateContentTestData(FeatureContext featureContext)
        {
            ITenantedContentStoreFactory contentStoreFactory = ContainerBindings.GetServiceProvider(featureContext).GetRequiredService <ITenantedContentStoreFactory>();
            IContentStore store = await contentStoreFactory.GetContentStoreForTenantAsync(featureContext.GetCurrentTenantId()).ConfigureAwait(false);

            for (int i = 0; i < 30; i++)
            {
                var content = new Content
                {
                    Id   = Guid.NewGuid().ToString(),
                    Slug = "slug",
                    Tags = new List <string> {
                        "First tag", "Second tag"
                    },
                    CategoryPaths = new List <string> {
                        "/standard/content;", "/books/hobbit;", "/books/lotr"
                    },
                    Author      = new CmsIdentity(Guid.NewGuid().ToString(), "Bilbo Baggins"),
                    Title       = "This is the title",
                    Description = "A description of the content",
                    Culture     = CultureInfo.GetCultureInfo("en-GB"),
                };

                Content storedContent = await store.StoreContentAsync(content).ConfigureAwait(false);

                featureContext.Set(storedContent, "Content" + i);
            }
        }
        public async Task WhenIGetTheContentSummariesForSlugWithLimitAndContinuationTokenAndCallIt(string slug, int limit, string continuationToken, string contentSummariesName)
        {
            IContentStore    store     = ContentManagementCosmosContainerBindings.GetContentStore(this.featureContext);
            ContentSummaries summaries = await store.GetContentSummariesAsync(SpecHelpers.ParseSpecValue <string>(this.scenarioContext, slug), limit, SpecHelpers.ParseSpecValue <string>(this.scenarioContext, continuationToken)).ConfigureAwait(false);

            this.scenarioContext.Set(summaries, contentSummariesName);
        }
Example #14
0
        public IActionResult EditContentSave(EditContentViewModel model)
        {
            if (ModelState.IsValid)
            {
                ICmsManager   manager      = new CmsManager();
                IContentStore contentStore = manager.GetContentStore(model.RepositoryId);
                ContentItem   item         = contentStore.Items.Where(m => m.Id == model.Item.Id).FirstOrDefault();

                IRepository repository = manager.GetRepositoryById(model.RepositoryId);
                model.ContentDefinition = repository.ContentDefinitions.Where(m => m.DefinitionId == model.DefinitionId).FirstOrDefault();

                if (item == null)
                {
                    item = FCms.Factory.ContentFactory.CreateContentByType(model.ContentDefinition);
                    model.MapToModel(item, Request);
                    contentStore.Items.Add(item);
                }
                else
                {
                    model.MapToModel(contentStore.GetById((Guid)model.Item.Id), Request);
                }
                manager.SaveContentStore(contentStore);
                return(Redirect("/fcmsmanager/pagecontent/list?repositoryid=" + model.RepositoryId + "&definitionid=" + item.DefinitionId.ToString()));
            }

            return(View("Edit", new RepositoryViewModel()));
        }
        void CreateTextContentValue()
        {
            contentStore = manager.GetContentStore(repositoryId);
            var contentItem = new StringContentItem()
            {
                Id           = Guid.NewGuid(),
                DefinitionId = definitionId,
                Data         = contentName
            };

            // add emil filter
            var emailcontentFilter = new ContentFilter()
            {
                FilterDefinitionId = regexFilterId
            };

            emailcontentFilter.Values.Add(@"(\w+)@gmail.com");
            contentItem.Filters.Add(emailcontentFilter);

            // add isloggedin filter
            var isloggedincontentFilter = new ContentFilter()
            {
                FilterDefinitionId = booleanFilterId
            };

            isloggedincontentFilter.Values.Add(true);
            contentItem.Filters.Add(isloggedincontentFilter);

            contentStore.Items.Add(contentItem);
            contentStore.Save();
        }
        public BuildCachePublishingStore(IContentStore contentSource, IAbsFileSystem fileSystem, int concurrencyLimit)
        {
            ContentSource = contentSource;
            FileSystem    = fileSystem;

            PublishingGate = new SemaphoreSlim(concurrencyLimit);
        }
Example #17
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="BuildCacheCache"/> class.
        /// </summary>
        /// <param name="fileSystem">Filesystem used to read/write files.</param>
        /// <param name="cacheNamespace">the namespace of the cache that is communicated with.</param>
        /// <param name="buildCacheHttpClientFactory">Factory for creatign a backing BuildCache http client.</param>
        /// <param name="backingContentStoreHttpClientFactory">Factory for creating a backing store http client.</param>
        /// <param name="maxFingerprintSelectorsToFetch">Maximum number of selectors to enumerate.</param>
        /// <param name="timeToKeepUnreferencedContent">Initial time-to-live for unreferenced content.</param>
        /// <param name="minimumTimeToKeepContentHashLists">Minimum time-to-live for created or referenced ContentHashLists.</param>
        /// <param name="rangeOfTimeToKeepContentHashLists">Range of time beyond the minimum for the time-to-live of created or referenced ContentHashLists.</param>
        /// <param name="logger">A logger for tracing.</param>
        /// <param name="fingerprintIncorporationEnabled">Feature flag to enable fingerprints incorporation on shutdown</param>
        /// <param name="maxDegreeOfParallelismForIncorporateRequests">Throttle the number of fingerprints chunks sent in parallel</param>
        /// <param name="maxFingerprintsPerIncorporateRequest">Max fingerprints allowed per chunk</param>
        /// <param name="writeThroughContentStoreFunc">Optional write-through store to allow writing-behind to BlobStore</param>
        /// <param name="sealUnbackedContentHashLists">If true, the client will attempt to seal any unbacked ContentHashLists that it sees.</param>
        /// <param name="useBlobContentHashLists">use blob based content hash lists.</param>
        /// <param name="downloadBlobsThroughBlobStore">If true, gets blobs through BlobStore. If false, gets blobs from the Azure Uri.</param>
        /// <param name="useDedupStore">If true, gets content through DedupStore. If false, gets content from BlobStore.</param>
        public BuildCacheCache(
            IAbsFileSystem fileSystem,
            string cacheNamespace,
            IBuildCacheHttpClientFactory buildCacheHttpClientFactory,
            IArtifactHttpClientFactory backingContentStoreHttpClientFactory,
            int maxFingerprintSelectorsToFetch,
            TimeSpan timeToKeepUnreferencedContent,
            TimeSpan minimumTimeToKeepContentHashLists,
            TimeSpan rangeOfTimeToKeepContentHashLists,
            ILogger logger,
            bool fingerprintIncorporationEnabled,
            int maxDegreeOfParallelismForIncorporateRequests,
            int maxFingerprintsPerIncorporateRequest,
            Func <IContentStore> writeThroughContentStoreFunc = null,
            bool sealUnbackedContentHashLists  = false,
            bool useBlobContentHashLists       = false,
            bool downloadBlobsThroughBlobStore = false,
            bool useDedupStore = false)
        {
            Contract.Requires(fileSystem != null);
            Contract.Requires(buildCacheHttpClientFactory != null);
            Contract.Requires(backingContentStoreHttpClientFactory != null);

            _fileSystem     = fileSystem;
            _cacheNamespace = cacheNamespace;
            _buildCacheHttpClientFactory = buildCacheHttpClientFactory;
            _tracer = new BuildCacheCacheTracer(logger, nameof(BuildCacheCache));

            _backingContentStore = new BackingContentStore(
                fileSystem, backingContentStoreHttpClientFactory, timeToKeepUnreferencedContent, _tracer.ContentSessionTracer, downloadBlobsThroughBlobStore, useDedupStore);

            if (useDedupStore)
            {
                // Guaranteed content is only available for BlobSessions. (bug 144396)
                _sealUnbackedContentHashLists = false;

                // BlobBuildCacheHttpClient is incompatible with Dedup hashes. (bug 1458510)
                _useBlobContentHashLists = false;
            }
            else
            {
                _sealUnbackedContentHashLists = sealUnbackedContentHashLists;
                _useBlobContentHashLists      = useBlobContentHashLists;
            }

            _maxFingerprintSelectorsToFetch    = maxFingerprintSelectorsToFetch;
            _minimumTimeToKeepContentHashLists = minimumTimeToKeepContentHashLists;
            _rangeOfTimeToKeepContentHashLists = rangeOfTimeToKeepContentHashLists;

            if (writeThroughContentStoreFunc != null)
            {
                _writeThroughContentStore = writeThroughContentStoreFunc();
                Contract.Assert(_writeThroughContentStore != null);
            }

            _fingerprintIncorporationEnabled = fingerprintIncorporationEnabled;
            _maxDegreeOfParallelismForIncorporateRequests = maxDegreeOfParallelismForIncorporateRequests;
            _maxFingerprintsPerIncorporateRequest         = maxFingerprintsPerIncorporateRequest;
        }
Example #18
0
        /// <nodoc />
        public VirtualizedContentStore(IContentStore innerStore, Logger logger, VfsCasConfiguration configuration)
        {
            _logger        = logger;
            _innerStore    = innerStore;
            _configuration = configuration;

            Tree = new VfsTree(_configuration);
        }
Example #19
0
 public ContentStorePreRequestUpdater(IContentStore <RadarrMovie> movieStore, IContentStore <SonarrTvShow> tvShowStore,
                                      IRadarrClient radarrClient, ISonarrClient sonarrClient)
 {
     _movieStore   = movieStore;
     _tvShowStore  = tvShowStore;
     _radarrClient = radarrClient;
     _sonarrClient = sonarrClient;
 }
Example #20
0
        public ContentManager(IContentStore <TEntry> store, IContentMetadataManager contentMetadataManager, IServiceProvider services)
        {
            this.contentMetadataManager = contentMetadataManager ?? throw new ArgumentNullException(nameof(contentMetadataManager));
            this.store    = store ?? throw new ArgumentNullException(nameof(store));
            this.services = services ?? throw new ArgumentNullException(nameof(services));

            modelMetadataProvider = contentMetadataManager.GetMetadata <TModel>();
        }
 public SaveContentItemCommandHandler(IContentStore store, IVersioner versioner, ContentItemValidator validator, ClaimsPrincipal currentUser, IDispatcher dispatcher)
 {
     _store       = store;
     _versioner   = versioner;
     _validator   = validator;
     _currentUser = currentUser;
     _dispatcher  = dispatcher;
 }
        public async Task WhenIGetTheContentForTheContentStateCalledAndCallItAsync(string stateName, string contentName)
        {
            ContentState  state   = this.scenarioContext.Get <ContentState>(stateName);
            IContentStore store   = ContentManagementCosmosContainerBindings.GetContentStore(this.featureContext);
            Content       content = await store.GetContentAsync(state.ContentId, state.Slug).ConfigureAwait(false);

            this.scenarioContext.Set(content, contentName);
        }
        public void ThenGettingThePublishedContentForSlugThrowsAContentNotFoundException(string slug)
        {
            IContentStore store = ContentManagementCosmosContainerBindings.GetContentStore(this.featureContext);

            Assert.ThrowsAsync <ContentNotFoundException>(
                () => store.GetPublishedContentAsync(SpecHelpers.ParseSpecValue <string>(this.scenarioContext, slug)),
                "ContentNotFoundException should have been thrown.");
        }
 public MultiplexedContentStore(Dictionary <string, IContentStore> drivesWithContentStore, string preferredCacheDrive)
 {
     Contract.Requires(!string.IsNullOrEmpty(preferredCacheDrive), "preferredCacheDrive should not be null or empty.");
     Contract.Requires(drivesWithContentStore?.Count > 0, "drivesWithContentStore should not be null or empty.");
     Contract.Check(drivesWithContentStore.ContainsKey(preferredCacheDrive))?.Requires($"drivesWithContentStore should contain '{preferredCacheDrive}'.");
     _drivesWithContentStore = drivesWithContentStore;
     _preferredCacheDrive    = preferredCacheDrive;
     PreferredContentStore   = drivesWithContentStore[preferredCacheDrive];
 }
Example #25
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="OneLevelCache" /> class.
        /// </summary>
        public OneLevelCache(Func <IContentStore> contentStoreFunc, Func <IMemoizationStore> memoizationStoreFunc, Guid id)
        {
            Contract.Requires(contentStoreFunc != null);
            Contract.Requires(memoizationStoreFunc != null);

            ContentStore     = contentStoreFunc();
            MemoizationStore = memoizationStoreFunc();
            Id = id;
        }
Example #26
0
        static async Task <int> RunStore(Context context, IContentStore store)
        {
            try
            {
                try
                {
                    StartupResult startupResult = await store.StartupAsync(context).ConfigureAwait(false);

                    if (startupResult.HasError)
                    {
                        throw new CacheException($"Failed to start store, error=[{startupResult.ErrorMessage}]");
                    }

                    var createSessionResult = store.CreateSession(context, "sample", ImplicitPin.None);
                    if (createSessionResult.HasError)
                    {
                        throw new CacheException($"Failed to create session, error=[{createSessionResult.ErrorMessage}]");
                    }

                    using (var session = createSessionResult.Session)
                    {
                        try
                        {
                            var sessionStartupResult = session.StartupAsync(context).Result;
                            if (sessionStartupResult.HasError)
                            {
                                throw new CacheException($"Failed to start session, error=[{createSessionResult.ErrorMessage}]");
                            }
                        }
                        finally
                        {
                            var sessionShutdownResult = session.ShutdownAsync(context).Result;
                            if (sessionShutdownResult.HasError)
                            {
                                context.Error($"Failed to shutdown session, error=[{sessionShutdownResult.ErrorMessage}]");
                            }
                        }
                    }
                }
                finally
                {
                    ShutdownResult shutdownResult = await store.ShutdownAsync(context).ConfigureAwait(false);

                    if (shutdownResult.HasError)
                    {
                        context.Error($"Failed to shutdown store, error=[{shutdownResult.ErrorMessage}]");
                    }
                }

                return(0);
            }
            catch (Exception)
            {
                return(1);
            }
        }
        public async Task WhenICopyTheContentFromSlugToAndCallIt(string sourceSlug, string destinationSlug, string copyName)
        {
            IContentStore store  = ContentManagementCosmosContainerBindings.GetContentStore(this.featureContext);
            Content       result = await store.CopyContentForPublicationAsync(
                SpecHelpers.ParseSpecValue <string>(this.scenarioContext, destinationSlug),
                SpecHelpers.ParseSpecValue <string>(this.scenarioContext, sourceSlug),
                new CmsIdentity("SomeId", "SomeName")).ConfigureAwait(false);

            this.scenarioContext.Set(result, copyName);
        }
Example #28
0
        public MultiLevelContentStore(
            IContentStore localContentStore,
            IContentStore backingContentStore)

        {
            Contract.RequiresNotNull(localContentStore);
            Contract.RequiresNotNull(backingContentStore);

            _localContentStore   = localContentStore;
            _backingContentStore = backingContentStore;
        }
Example #29
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="OneLevelCache" /> class.
        /// </summary>
        /// <remarks>
        ///     It is assumed that the produced sessions are different objects.
        /// </remarks>
        public OneLevelCache(Func <IContentStore> contentStoreFunc, Func <IMemoizationStore> memoizationStoreFunc, Guid id)
        {
            Contract.Requires(contentStoreFunc != null);
            Contract.Requires(memoizationStoreFunc != null);

            ContentStore     = contentStoreFunc();
            MemoizationStore = memoizationStoreFunc();
            Id = id;

            Contract.Assert(!ReferenceEquals(ContentStore, MemoizationStore));
        }
        public async Task WhenIGetThePublishedStateHistoryAndCorrespondingContentSummariesForSlugAndCallIt(string slug, int limit, string continuationToken, string name)
        {
            IContentStore store  = ContentManagementCosmosContainerBindings.GetContentStore(this.featureContext);
            ContentStates states = await store.GetPublishedHistory(
                SpecHelpers.ParseSpecValue <string>(this.scenarioContext, slug),
                limit,
                SpecHelpers.ParseSpecValue <string>(this.scenarioContext, continuationToken)).ConfigureAwait(false);

            List <ContentSummary> summaries = await store.GetContentSummariesForStatesAsync(states.States).ConfigureAwait(false);

            this.scenarioContext.Set((states, summaries), name);
        }
Example #31
0
 public HttpCache(IContentStore contentStore)
 {
     _contentStore = contentStore;
     SharedCache = false;
 }
 public HttpCache(IContentStore contentStore)
 {
     _contentStore = contentStore;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MediaVirtualPathProvider"/> class.
 /// </summary>
 public MediaVirtualPathProvider()
 {
     _contentStore = StoreManager.ContentStore;
 }