Ejemplo n.º 1
0
 protected override void Unpublished(PublishContentContext context) {
     var contentTags = context.ContentItem.As<TagsPart>();
     if (contentTags != null) {
         _signals.Trigger(TagCloudService.VandelayTagcloudTagschanged);
     }
     base.Unpublished(context);
 }
Ejemplo n.º 2
0
        public void Publishing(PublishContentContext context, FieldIndexPart fieldIndexPart) {
            foreach (var part in fieldIndexPart.ContentItem.Parts) {
                foreach(var field in part.PartDefinition.Fields) {
                    
                    // get all drivers for the current field type
                    // the driver will describe what values of the field should be indexed
                    var drivers = _contentFieldDrivers.Where(x => x.GetFieldInfo().Any(fi => fi.FieldTypeName == field.FieldDefinition.Name)).ToList();
                    
                    ContentPart localPart = part;
                    ContentPartFieldDefinition localField = field;
                    var membersContext = new DescribeMembersContext( 
                        (storageName, storageType, displayName, description) => {
                            var fieldStorage = _fieldStorageProvider.BindStorage(localPart, localField);

                            // fieldStorage.Get<T>(storageName)
                            var getter = typeof(IFieldStorage).GetMethod("Get").MakeGenericMethod(storageType);
                            var fieldValue = getter.Invoke(fieldStorage, new[] {storageName});

                            _fieldIndexService.Set(fieldIndexPart,
                                localPart.PartDefinition.Name,
                                localField.Name,
                                storageName, fieldValue, storageType);
                        });

                    foreach (var driver in drivers) {
                        driver.Describe(membersContext);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 protected override void Unpublished(PublishContentContext context)
 {
     var contentTags = context.ContentItem.As<TagsPart>();
     if (contentTags != null) {
         _signals.Trigger(TagsMenuItemEvent.TagsChanged);
     }
     base.Unpublished(context);
 }
Ejemplo n.º 4
0
 private void OnPublishing(PublishContentContext context, EntityMetadataPart part) {
     if (context.PreviousItemVersionRecord == null) {
         CreateEntity(part);
     }
     else {
         var previousEntity = _contentManager.Get<EntityMetadataPart>(context.Id);
         UpdateEntity(previousEntity, part);
     }
 }
 void CreateIndexingTask(PublishContentContext context, ContentPart part) {
     // "Unpublish" case: Same as "remove"
     if (context.PublishingItemVersionRecord == null) {
         _indexingTaskManager.CreateDeleteIndexTask(context.ContentItem);
         return;
     }
     // "Publish" case: update index
     _indexingTaskManager.CreateUpdateIndexTask(context.ContentItem);
 }
 protected override void Unpublished(PublishContentContext context)
 {
     var contentTags = context.ContentItem.As<TagsPart>();
     if (contentTags != null)
     {
         _signals.Trigger(LocalizedTagsService._localizedTagcloudTagsChanged);
     }
     base.Unpublished(context);
 }
Ejemplo n.º 7
0
 private void DeferOrPublishAssets(PublishContentContext context, CloudVideoPart part) {
     if (part.MezzanineAsset != null && part.MezzanineAsset.UploadState.Status != AssetUploadStatus.Uploaded) {
         part.PublishOnUpload = true;
         _notifier.Warning(T("The cloud video item was saved, but will not be published until the primary video asset has finished uploading to Windows Azure Media Services."));
         context.Cancel = true;
     }
     else
         _assetManager.PublishAssetsFor(part);
 }
Ejemplo n.º 8
0
        private void ScheduleUnpublish(PublishContentContext ctx, ProductPart part) {
            _scheduledTaskManager.DeleteTasks(part.ContentItem, t => t.TaskType == Constants.UnpublishTaskName);

            var settings = _workContextAccessor.GetContext().CurrentSite.Get<ProductSettingsPart>();
            if (settings.HideProductDelay > 0) {
                // Schedule the unpublish moment
                var dateToUnpublish = DateTime.UtcNow.AddDays(settings.HideProductDelay);
                _scheduledTaskManager.CreateTask(Constants.UnpublishTaskName, dateToUnpublish, part.ContentItem);
            }
        }
Ejemplo n.º 9
0
        public override void Published(PublishContentContext context)
        {
            var utcNow = _clock.UtcNow;

            // The first time the content is published, reassign the CreateUtc value
            if(!context.ContentItem.PublishedUtc.HasValue)
            {
                context.ContentItem.CreatedUtc = utcNow;
            }

            context.ContentItem.PublishedUtc = utcNow;
        }
        private void UpdateContentItemRoleSecurityRecords(PublishContentContext context, ContentItem contentItem) {
            var roles = _roleService.GetRoles();

            var allowedRoles = new List<RoleRecord>();

            bool canAnonView = _authorizationService.TryCheckAccess(
                _permission, 
                null /* null signifies anon user */,
                contentItem);

            foreach (var role in roles) {
                var user = UserSimulation.Create(role.Name);

                if (_authorizationService.TryCheckAccess(
                        _permission, 
                        user,
                        contentItem)
                    ) {

                    allowedRoles.Add(role);
                }
            }

            /* Delete and maintain a fresh one on each publish */
            var currentRecord = _roleSecurityRepository
                .Get(o => o.ContentItemRecord == contentItem.Record);

            if (currentRecord != null)
                _roleSecurityRepository.Delete(currentRecord);

            PermissionRecord permissionRecord = _permissionRepository
                .Get(x => x.Name == _permission.Name);

            var entity = new RoleSecurityRecord{
                ContentItemRecord = contentItem.Record,
                AnonymousCanView = canAnonView,
                Permission = permissionRecord};

            _roleSecurityRepository.Create(entity);

            foreach (var allowedRole in allowedRoles) {
                entity.RolesSecurities.Add(
                    new RolesSecuritiesRecord{
                        Role = allowedRole,
                        RoleSecurity = entity });
            }
        }
Ejemplo n.º 11
0
 protected override void  Published(PublishContentContext context)
 {
     // Check inverse of connector
     var part = context.ContentItem.As<ConnectorPart>();
     if (part!=null) {
         if (part.InverseConnector != null) {
             // Make sure inverse has the correct version
             part.InverseConnector.RightContentVersionId = part.LeftContentVersionId;
             // Publish the inverse
             if (!part.InverseConnector.IsPublished()) {
                 Services.ContentManager.Publish(part.InverseConnector.ContentItem);
             }
         }
     } 
     // Publish all connectors of socket
     var socket = context.ContentItem.As<SocketsPart>();
     if (socket!=null) {
         socket.Sockets.Flush();
         PublishConnectors(socket);
         // TODO: PERF: Could end up with a lot of overhead and triggering all the time when, say, adding comments or any old thing. Actually only need to do this for
         // specific things like menus.
         Trigger(socket);
     }
 }
Ejemplo n.º 12
0
 private void UpdatePublishedValues(PublishContentContext context, VersionInfoPart part)
 {
     part.Draft = false;
     part.Removed = false;
 }
Ejemplo n.º 13
0
 protected override void Published(PublishContentContext context) {
     if (context.ContentItem.Has<ImageProfilePart>())
         _signals.Trigger("MediaProcessing_Published_" + context.ContentItem.As<ImageProfilePart>().Name);
     base.Published(context);
 }
Ejemplo n.º 14
0
 void Generate(PublishContentContext context, ContentPart part) {
     if(_orchardServices.WorkContext.CurrentSite.As<WarmupSettingsPart>().OnPublish) {
         _warmupScheduler.Schedule(true);
     }
 }
Ejemplo n.º 15
0
 protected virtual void Publishing(PublishContentContext context)
 {
 }
Ejemplo n.º 16
0
 private void UpdateTemplateClients(PublishContentContext context, LayoutPart part) {
     UpdateTemplateClients(part);
 }
Ejemplo n.º 17
0
 private static void CreateFilterGroup(PublishContentContext ctx, QueryPart part) {
     if (!part.FilterGroups.Any()) {
         part.FilterGroups.Add(new FilterGroupRecord());
     }
 }
Ejemplo n.º 18
0
        public async Task Publish(ContentItem contentItem) {
            if (contentItem.VersionRecord.Published) {
                return;
            }
            // create a context for the item and it's previous published record
            var previous = await _session
                .QueryAsync<ContentItemVersionRecord, ContentItemVersionRecordIndex>(x => 
                    x.ContentItemId == contentItem.Id && x.Published)
                .FirstOrDefault();

            var context = new PublishContentContext(contentItem, previous);

            // invoke handlers to acquire state, or at least establish lazy loading callbacks
            Handlers.Invoke(handler => handler.Publishing(context), _logger);

            if (context.Cancel) {
                return;
            }

            if (previous != null) {
                previous.Published = false;
            }
            contentItem.VersionRecord.Published = true;

            Handlers.Invoke(handler => handler.Published(context), _logger);
        }
 void IContentHandler.Publishing(PublishContentContext context)
 {
 }
 public void Unpublished(PublishContentContext context)
 {
     TriggerIfGraph(context);
 }
Ejemplo n.º 21
0
        public virtual void Create(ContentItem contentItem, VersionOptions options)
        {
            if (contentItem.Number == 0)
            {
                contentItem.Number = 1;
                contentItem.Latest = true;
                contentItem.Published = true;
            }

            // Version may be specified
            if (options.VersionNumber != 0)
            {
                contentItem.Number = options.VersionNumber;
            }

            // Draft flag on create is required for explicitly-published content items
            if (options.IsDraft)
            {
                contentItem.Published = false;
            }

            // Build a context with the initialized instance to create
            var context = new CreateContentContext(contentItem);

            // invoke handlers to add information to persistent stores
            Handlers.Invoke(handler => handler.Creating(context), _logger);

            Handlers.Invoke(handler => handler.Created(context), _logger);

            if (options.IsPublished)
            {
                var publishContext = new PublishContentContext(contentItem, null);

                // invoke handlers to acquire state, or at least establish lazy loading callbacks
                Handlers.Invoke(handler => handler.Publishing(publishContext), _logger);

                // invoke handlers to acquire state, or at least establish lazy loading callbacks
                Handlers.Invoke(handler => handler.Published(publishContext), _logger);
            }

            _session.Save(contentItem);
            _contentManagerSession.Store(contentItem);
        }
Ejemplo n.º 22
0
 public virtual void Publishing(PublishContentContext context, TPart instance)
 {
 }
Ejemplo n.º 23
0
        public async Task PublishAsync(ContentItem contentItem)
        {
            if (contentItem.Published)
            {
                return;
            }

            // Create a context for the item and it's previous published record
            // Because of this query the content item will need to be re-enlisted
            // to be saved.
            var previous = await _session
                .QueryAsync<ContentItem, ContentItemIndex>(x =>
                    x.ContentItemId == contentItem.ContentItemId && x.Published)
                .FirstOrDefault();

            var context = new PublishContentContext(contentItem, previous);

            // invoke handlers to acquire state, or at least establish lazy loading callbacks
            Handlers.Invoke(handler => handler.Publishing(context), _logger);

            if (context.Cancel)
            {
                return;
            }

            if (previous != null)
            {
                _session.Save(previous);
                previous.Published = false;
            }

            contentItem.Published = true;

            _session.Save(contentItem);

            Handlers.Invoke(handler => handler.Published(context), _logger);
        }
Ejemplo n.º 24
0
 protected override void  Unpublishing(PublishContentContext context)
 {
     var part = context.ContentItem.As<SocketsPart>();
     if (part!=null)
         UnpublishSocket(part);
 }
Ejemplo n.º 25
0
        private void FinalizePath(RoutePart route, PublishContentContext context, Action<RoutePart> processSlug) {
            var path = route.Path;
            route.Path = route.GetPathWithSlug(route.Slug);

            if (context.PublishingItemVersionRecord != null)
                processSlug(route);

            // if the path has changed by having the slug changed on the way in (e.g. user input) or to avoid conflict
            // then update and publish all contained items
            if (path != route.Path) {
                _routablePathConstraint.RemovePath(path);
                _routableService.FixContainedPaths(route);
            }

            if (!string.IsNullOrWhiteSpace(route.Path))
                _routablePathConstraint.AddPath(route.Path);
        }
Ejemplo n.º 26
0
 public virtual void Unpublished(PublishContentContext context, TPart instance)
 {
 }
 public void Unpublishing(PublishContentContext context)
 {
 }
Ejemplo n.º 28
0
 private void CancelAndUnpublishAssets(PublishContentContext context, CloudVideoPart part) {
     part.PublishOnUpload = false;
     _assetManager.UnpublishAssetsFor(part);
 }
Ejemplo n.º 29
0
 protected virtual void Unpublished(PublishContentContext context)
 {
 }
Ejemplo n.º 30
0
        protected override void  Unpublished(PublishContentContext context)
        {
 	        base.Unpublished(context);
        }
Ejemplo n.º 31
0
        public virtual void Create(ContentItem contentItem, VersionOptions options) {
            if (contentItem.VersionRecord == null) {
                // produce root record to determine the model id
                contentItem.VersionRecord = new ContentItemVersionRecord {
                    Number = 1,
                    Latest = true,
                    Published = true
                };
            }

            // add to the collection manually for the created case
            contentItem.VersionRecord.ContentType = contentItem.ContentType;

            // version may be specified
            if (options.VersionNumber != 0) {
                contentItem.VersionRecord.Number = options.VersionNumber;
            }

            // draft flag on create is required for explicitly-published content items
            if (options.IsDraft) {
                contentItem.VersionRecord.Published = false;
            }

            // build a context with the initialized instance to create
            var context = new CreateContentContext(contentItem);

            // invoke handlers to add information to persistent stores
            Handlers.Invoke(handler => handler.Creating(context), _logger);

            Handlers.Invoke(handler => handler.Created(context), _logger);

            if (options.IsPublished) {
                var publishContext = new PublishContentContext(contentItem, null);

                // invoke handlers to acquire state, or at least establish lazy loading callbacks
                Handlers.Invoke(handler => handler.Publishing(publishContext), _logger);

                // invoke handlers to acquire state, or at least establish lazy loading callbacks
                Handlers.Invoke(handler => handler.Published(publishContext), _logger);
            }

            _session.Save(contentItem.Record);
            contentItem.VersionRecord.ContentItemId = contentItem.Record.Id;
            _session.Save(contentItem.VersionRecord);

            _contentManagerSession.Store(contentItem);
        }
Ejemplo n.º 32
0
        public async Task UnpublishAsync(ContentItem contentItem)
        {
            ContentItem publishedItem;
            if (contentItem.Published)
            {
                // The version passed in is the published one
                publishedItem = contentItem;
            }
            else
            {
                // Try to locate the published version of this item
                publishedItem = await GetAsync(contentItem.ContentItemId, VersionOptions.Published);
            }

            if (publishedItem == null)
            {
                // No published version exists. no work to perform.
                return;
            }

            // Create a context for the item. the publishing version is null in this case
            // and the previous version is the one active prior to unpublishing. handlers
            // should take this null check into account
            var context = new PublishContentContext(contentItem, publishedItem)
            {
                PublishingItem = null
            };

            Handlers.Invoke(handler => handler.Unpublishing(context), _logger);

            publishedItem.Published = false;

            _session.Save(contentItem);

            Handlers.Invoke(handler => handler.Unpublished(context), _logger);
        }
Ejemplo n.º 33
0
 protected override void  Publishing(PublishContentContext context)
 {
     base.Publishing(context);
 }
Ejemplo n.º 34
0
 protected void AssignPublishingDates(PublishContentContext context, CommonPart part) {
     var utcNow = _clock.UtcNow;
     part.PublishedUtc = utcNow;
     part.VersionPublishedUtc = utcNow;
 }
Ejemplo n.º 35
0
        public override void Unpublished(PublishContentContext context)
        {
            var utcNow = _clock.UtcNow;

            context.ContentItem.PublishedUtc = null;
        }