コード例 #1
0
        public void CopyContentProperties_OutstandingDraftAndNotInOverwriteMode_ReturnsFailureStatus()
        {
            // Arrange
            var testLanguage = CultureInfo.GetCultureInfo(testLanguageCode);

            var sourcePageReference      = new ContentReference(sourcePageId);
            var destinationPageReference = new ContentReference(destinationPageId);

            var request = new ContentCopyRequestDetail
            {
                Source      = sourcePageId,
                Destination = destinationPageId,
                Properties  = new List <string> {
                    "SampleProperty", "Other Property"
                },
                CultureCode = testLanguageCode
            };

            var pendingCommonDraft = new ContentVersion(destinationPageReference, "draft", VersionStatus.CheckedIn, DateTime.Now,
                                                        "test", "sample user", destinationPageId, testLanguageCode, true, true);

            _stubContentVersionRepository.LoadCommonDraft(destinationPageReference, testLanguageCode).Returns(pendingCommonDraft);

            _stubContentLoader.Get <PageData>(sourcePageReference, testLanguage).Returns(new PageData());
            _stubContentLoader.Get <PageData>(destinationPageReference, testLanguage).Returns(new PageData());

            // Act
            var result = _propertyService.CopyContentProperties(request);

            // Assert
            Assert.IsFalse(result.Success);
        }
コード例 #2
0
        public ContentReference LoadUnpublishedVersion(ContentReference baseReference)
        {
            if (ExternalReview.ProjectId.HasValue)
            {
                // load version from project
                return(_projectContentResolver.GetProjectReference(baseReference,
                                                                   ExternalReview.ProjectId.Value, _languageResolver.GetPreferredCulture().Name));
            }

            // load common draft instead of published version
            ContentVersion loadCommonDraft;

            try
            {
                loadCommonDraft = _contentVersionRepository.LoadCommonDraft(baseReference, _languageResolver.GetPreferredCulture().Name);
            }
            catch (ContentNotFoundException)
            {
                _log.Debug($"Advanced Reviews: Content {baseReference} not found for LoadUnpublishedVersion");
                loadCommonDraft = null;
            }

            if (loadCommonDraft == null)
            {
                // fallback to default implementation if there is no common draft in a given language
                return(null);
            }

            return(loadCommonDraft.ContentLink);
        }
コード例 #3
0
        public IContent Get(ContentAreaItem contentAreaItem)
        {
            if (!ExternalReview.IsInExternalReviewContext)
            {
                return(_defaultContentAreaLoader.Get(contentAreaItem));
            }

            // load common draft instead of published version
            var commonDraft = _contentVersionRepository.LoadCommonDraft(contentAreaItem.ContentLink,
                                                                        _languageResolver.GetPreferredCulture().Name);

            if (commonDraft != null)
            {
                var content = _contentLoader.Get <IContent>(commonDraft.ContentLink);
                if (content.IsPublished())
                {
                    // for published version return the original method result
                    var defaultContent = _defaultContentAreaLoader.Get(contentAreaItem);
                    return(defaultContent);
                }

                contentAreaItem.ContentLink = commonDraft.ContentLink;

                return(content);
            }

            return(_defaultContentAreaLoader.Get(contentAreaItem));
        }
        public IEnumerable <EnhancedStructureStoreContentDataModel> GetLatestVersions(IEnumerable <ContentReference> ids,
                                                                                      NameValueCollection queryString)
        {
            if (ids == null)
            {
                return(null);
            }

            var draftLinks = new List <ContentReference>();

            foreach (var id in ids)
            {
                if (_currentProject.ProjectId.HasValue)
                {
                    var projectReference = _projectContentResolver.GetProjectReference(id, _currentProject.ProjectId.Value);
                    draftLinks.Add(projectReference);
                    continue;
                }

                var content = _contentLoader.Get <IContent>(id) as IVersionable;
                if (content == null)
                {
                    draftLinks.Add(id);
                    continue;
                }

                if (content.Status == VersionStatus.Published)
                {
                    var contentVersion =
                        _contentVersionRepository.LoadCommonDraft(id, _languageResolver.GetPreferredCulture().Name);
                    if (contentVersion != null)
                    {
                        draftLinks.Add(contentVersion.ContentLink);
                        continue;
                    }
                }

                draftLinks.Add(id);
            }

            var contents = _contentLoader.GetItems(draftLinks,
                                                   new LoaderOptions {
                LanguageLoaderOption.FallbackWithMaster()
            });
            var queryParameters = new ContentQueryParameters
            {
                AllParameters    = queryString,
                CurrentPrincipal = PrincipalInfo.CurrentPrincipal
            };

            // The ContentVersionFilter modify content links.
            // We have to use this filter here to make sure that we will use proper links
            return(_contentStoreModelCreator
                   .CreateContentDataStoreModels <EnhancedStructureStoreContentDataModel>(contents, queryParameters).ToList());
        }
コード例 #5
0
        public IContent Get(ContentAreaItem contentAreaItem)
        {
            if (!ExternalReview.IsInExternalReviewContext)
            {
                return(_defaultContentAreaLoader.Get(contentAreaItem));
            }

            ContentReference referenceToLoad;

            if (ExternalReview.ProjectId.HasValue)
            {
                // load version from project
                referenceToLoad = _projectContentResolver.GetProjectReference(contentAreaItem.ContentLink,
                                                                              ExternalReview.ProjectId.Value);
            }
            else
            {
                // load common draft instead of published version
                var loadCommonDraft = _contentVersionRepository.LoadCommonDraft(contentAreaItem.ContentLink,
                                                                                _languageResolver.GetPreferredCulture().Name);
                if (loadCommonDraft == null)
                {
                    // fallback to default implementation if there is no common draft in a given language
                    return(_defaultContentAreaLoader.Get(contentAreaItem));
                }
                referenceToLoad = loadCommonDraft.ContentLink;
            }

            if (referenceToLoad != null)
            {
                var content = _contentLoader.Get <IContent>(referenceToLoad);
                if (HasExpired(content as IVersionable))
                {
                    return(null);
                }

                if (content.IsPublished())
                {
                    // for published version return the original method result
                    return(_defaultContentAreaLoader.Get(contentAreaItem));
                }

                if (!contentAreaItem.IsReadOnly)
                {
                    contentAreaItem.ContentLink = referenceToLoad;
                }

                return(content);
            }

            return(_defaultContentAreaLoader.Get(contentAreaItem));
        }
コード例 #6
0
        public ContentReference LoadUnpublishedVersion(ContentReference baseReference)
        {
            if (ExternalReview.ProjectId.HasValue)
            {
                // load version from project
                return(_projectContentResolver.GetProjectReference(baseReference,
                                                                   ExternalReview.ProjectId.Value, _languageResolver.GetPreferredCulture().Name));
            }

            // load common draft instead of published version
            var loadCommonDraft = _contentVersionRepository.LoadCommonDraft(baseReference, _languageResolver.GetPreferredCulture().Name);

            if (loadCommonDraft == null)
            {
                // fallback to default implementation if there is no common draft in a given language
                return(null);
            }

            return(loadCommonDraft.ContentLink);
        }
コード例 #7
0
        public IContent Get(ContentAreaItem contentAreaItem)
        {
            if (!ExternalReview.IsInExternalReviewContext)
            {
                return(_defaultContentAreaLoader.Get(contentAreaItem));
            }

            ContentReference referenceToLoad;

            if (ExternalReview.ProjectId.HasValue)
            {
                // load version from project
                referenceToLoad = _projectContentResolver.GetProjectReference(contentAreaItem.ContentLink,
                                                                              ExternalReview.ProjectId.Value);
            }
            else
            {
                // load common draft instead of published version
                referenceToLoad = _contentVersionRepository.LoadCommonDraft(contentAreaItem.ContentLink,
                                                                            _languageResolver.GetPreferredCulture().Name).ContentLink;
            }

            if (referenceToLoad != null)
            {
                var content = _contentLoader.Get <IContent>(referenceToLoad);
                if (content.IsPublished())
                {
                    // for published version return the original method result
                    var defaultContent = _defaultContentAreaLoader.Get(contentAreaItem);
                    return(defaultContent);
                }

                contentAreaItem.ContentLink = referenceToLoad;

                return(content);
            }

            return(_defaultContentAreaLoader.Get(contentAreaItem));
        }
コード例 #8
0
        private bool ContentHasOutstandingDraft(int contentId, string language)
        {
            var commonDraft = _contentVersionRepository.LoadCommonDraft(new ContentReference(contentId), language);

            return(commonDraft.Status != VersionStatus.Published);
        }
コード例 #9
0
        private IContent GetDraftedContent(ContentReference contentLink)
        {
            var versions = _contentVersionRepository.LoadCommonDraft(contentLink, "en");

            return(_contentRepository.Get <IContent>(versions.ContentLink));
        }