Beispiel #1
0
        /// <summary>Restores an item to the original location.</summary>
        /// <param name="item">The item to restore.</param>
        public virtual void Restore(ContentItem item)
        {
            ContentItem parent = (ContentItem)item["FormerParent"];

            RestoreValues(item);
            persister.Save(item);
            persister.Move(item, parent);
        }
Beispiel #2
0
        public void TrashedItem_MovedFromTrashcan_IsUnexpired()
        {
            PutItemInTrash();

            var th = CreateTrashHandler();

            th.UseNavigationMode = true;
            th.RestoreValues(item);
            DeleteInterceptor interceptor = new DeleteInterceptor(persister, th);

            interceptor.Start();

            // now restore through drag&drop
            persister.Move(item, root);

            item.Parent.ShouldBe(root);
            item[TrashHandler.DeletedDate].ShouldBe(null);
        }
 private void MoveTranslations(ContentItem item, ILanguage language, ContentItem destination)
 {
     foreach (ContentItem translatedItem in gateway.FindTranslations(item))
     {
         ILanguage   translationsLanguage  = gateway.GetLanguage(translatedItem);
         ContentItem translatedDestination = gateway.GetTranslation(destination, translationsLanguage);
         if (translationsLanguage != language && translatedDestination != null && translatedItem.Parent != translatedDestination)
         {
             persister.Move(translatedItem, translatedDestination);
         }
     }
 }
Beispiel #4
0
        /// <summary>Throws an item in a way that it later may be restored to it's original location at a later stage.</summary>
        /// <param name="item">The item to throw.</param>
        public virtual void Throw(ContentItem item)
        {
            CancellableItemEventArgs args = Invoke <CancellableItemEventArgs>(ItemThrowing, new CancellableItemEventArgs(item));

            if (!args.Cancel)
            {
                item = args.AffectedItem;

                ExpireTrashedItem(item);

                try
                {
                    persister.Move(item, GetTrashContainer(true));
                }
                catch (PermissionDeniedException ex)
                {
                    throw new PermissionDeniedException("Permission denied while moving item to trash. Try disabling security checks using N2.Context.Security or preventing items from beeing moved to the trash with the [NonThrowable] attribute", ex);
                }

                Invoke <ItemEventArgs>(ItemThrowed, new ItemEventArgs(item));
            }
        }
Beispiel #5
0
        private TrashHandler CreateTrashHandler()
        {
            ContentActivator activator = new ContentActivator(null, null, null);
            IPersister       persister = MockPersister(root, trash, item);

            Expect.Call(delegate { persister.Move(null, null); }).IgnoreArguments()
            .Do(new System.Action <ContentItem, ContentItem>(delegate(ContentItem source, ContentItem destination)
            {
                source.AddTo(destination);
            })).Repeat.Any();

            mocks.ReplayAll();

            return(new TrashHandler(persister, null, null, new ContainerRepository <TrashContainerItem>(persister, null, host, activator), new StateChanger())
            {
                UseNavigationMode = true
            });
        }