public void ShouldRebasePathOfChildren() { var root = new FakeItem(children: new[] { new FakeItem() }, id:Guid.NewGuid()); var rebase = new PathRebasingItemData(root, "/sitecore/new", Guid.NewGuid()); rebase.GetChildren().First().Path.Should().Be("/sitecore/new/test item/test item"); rebase.GetChildren().First().ParentId.Should().Be(root.Id); }
public void ShouldRebasePathOfChildren() { var root = new FakeItem(children: new[] { new FakeItem() }, id: Guid.NewGuid()); var rebase = new PathRebasingItemData(root, "/sitecore/new", Guid.NewGuid()); rebase.GetChildren().First().Path.Should().Be("/sitecore/new/test item/test item"); rebase.GetChildren().First().ParentId.Should().Be(root.Id); }
public void ShouldRebasePath() { var root = new FakeItem(); var pid = Guid.NewGuid(); var rebase = new PathRebasingItemData(root, "/sitecore/new", pid); rebase.Path.Should().Be("/sitecore/new/test item"); rebase.ParentId.Should().Be(pid); }
public void MoveItem(ItemDefinition itemDefinition, ItemDefinition destination, CallContext context) { if (DisableSerialization) return; Assert.ArgumentNotNull(itemDefinition, "itemDefinition"); var sourceItem = GetSourceFromId(itemDefinition.ID, true); // we use cache here because we want the old path (no cache would have the new path); TpSync always has old path var oldPath = sourceItem.Path; // NOTE: we cap the path here, because Sitecore can change the item's path value as we're updating stuff. var destinationItem = GetSourceFromId(destination.ID); if (destinationItem == null) return; // can occur with TpSync on, when this isn't the configuration we're moving for the data store will return null if (!_predicate.Includes(destinationItem).IsIncluded) // if the destination we are moving to is NOT included for serialization, we delete the existing item { var existingItem = _targetDataStore.GetByPathAndId(sourceItem.Path, sourceItem.Id, sourceItem.DatabaseName); if (existingItem != null) { _targetDataStore.Remove(existingItem); _logger.MovedItemToNonIncludedLocation(_targetDataStore.FriendlyName, existingItem); } return; } // rebase the path to the new destination path (this handles children too) var rebasedSourceItem = new PathRebasingItemData(sourceItem, destinationItem.Path, destinationItem.Id); // this allows us to filter out any excluded children by predicate when the data store moves children var predicatedItem = new PredicateFilteredItemData(rebasedSourceItem, _predicate); _targetDataStore.MoveOrRenameItem(predicatedItem, oldPath); _logger.MovedItem(_targetDataStore.FriendlyName, predicatedItem, destinationItem); }