diff --git a/build/NuSpecs/tools/trees.config.install.xdt b/build/NuSpecs/tools/trees.config.install.xdt
index 65aa9c2b53..21dc791636 100644
--- a/build/NuSpecs/tools/trees.config.install.xdt
+++ b/build/NuSpecs/tools/trees.config.install.xdt
@@ -43,7 +43,7 @@
xdt:Locator="Match(application,alias)"
xdt:Transform="InsertIfMissing" />
-
> _id2Key = new Dictionary>();
private readonly Dictionary> _key2Id = new Dictionary>();
@@ -39,8 +39,8 @@ namespace Umbraco.Core.Services
int? val;
using (var uow = _uowProvider.GetUnitOfWork())
{
- val = uow.Database.ExecuteScalar("SELECT id FROM umbracoNode WHERE uniqueId=@id AND nodeObjectType=@nodeObjectType",
- new { id = key, nodeObjectType = GetNodeObjectTypeGuid(umbracoObjectType) });
+ val = uow.Database.ExecuteScalar("SELECT id FROM umbracoNode WHERE uniqueId=@id AND (nodeObjectType=@type OR nodeObjectType=@reservation)",
+ new { id = key, type = GetNodeObjectTypeGuid(umbracoObjectType), reservation = Constants.ObjectTypes.IdReservationGuid });
uow.Commit();
}
@@ -92,8 +92,8 @@ namespace Umbraco.Core.Services
Guid? val;
using (var uow = _uowProvider.GetUnitOfWork())
{
- val = uow.Database.ExecuteScalar("SELECT uniqueId FROM umbracoNode WHERE id=@id AND nodeObjectType=@nodeObjectType",
- new { id, nodeObjectType = GetNodeObjectTypeGuid(umbracoObjectType) });
+ val = uow.Database.ExecuteScalar("SELECT uniqueId FROM umbracoNode WHERE id=@id AND (nodeObjectType=@type OR nodeObjectType=@reservation)",
+ new { id, type = GetNodeObjectTypeGuid(umbracoObjectType), reservation = Constants.ObjectTypes.IdReservationGuid });
uow.Commit();
}
@@ -179,7 +179,7 @@ namespace Umbraco.Core.Services
{
private readonly T _id;
private readonly UmbracoObjectTypes _umbracoObjectType;
-
+
public T Id
{
get { return _id; }
diff --git a/src/Umbraco.Tests/Services/EntityServiceTests.cs b/src/Umbraco.Tests/Services/EntityServiceTests.cs
index 021c0d6c36..0dee46e07e 100644
--- a/src/Umbraco.Tests/Services/EntityServiceTests.cs
+++ b/src/Umbraco.Tests/Services/EntityServiceTests.cs
@@ -26,15 +26,15 @@ namespace Umbraco.Tests.Services
public override void TearDown()
{
base.TearDown();
- }
+ }
[Test]
public void EntityService_Can_Get_Paged_Content_Children()
{
-
+
var contentType = ServiceContext.ContentTypeService.GetContentType("umbTextpage");
-
- var root = MockedContent.CreateSimpleContent(contentType);
+
+ var root = MockedContent.CreateSimpleContent(contentType);
ServiceContext.ContentService.Save(root);
for (int i = 0; i < 10; i++)
{
@@ -45,7 +45,7 @@ namespace Umbraco.Tests.Services
var service = ServiceContext.EntityService;
long total;
- var entities = service.GetPagedChildren(root.Id, UmbracoObjectTypes.Document, 0, 6, out total).ToArray();
+ var entities = service.GetPagedChildren(root.Id, UmbracoObjectTypes.Document, 0, 6, out total).ToArray();
Assert.That(entities.Length, Is.EqualTo(6));
Assert.That(total, Is.EqualTo(10));
entities = service.GetPagedChildren(root.Id, UmbracoObjectTypes.Document, 1, 6, out total).ToArray();
@@ -72,7 +72,7 @@ namespace Umbraco.Tests.Services
var c2 = MockedContent.CreateSimpleContent(contentType, Guid.NewGuid().ToString(), c1);
ServiceContext.ContentService.Save(c2);
count++;
- }
+ }
}
var service = ServiceContext.EntityService;
@@ -181,7 +181,7 @@ namespace Umbraco.Tests.Services
var root = MockedContent.CreateSimpleContent(contentType);
ServiceContext.ContentService.Save(root);
-
+
for (int i = 0; i < 10; i++)
{
var c1 = MockedContent.CreateSimpleContent(contentType, "ssss" + Guid.NewGuid(), root);
@@ -204,7 +204,7 @@ namespace Umbraco.Tests.Services
Assert.That(entities.Length, Is.EqualTo(50));
Assert.That(total, Is.EqualTo(50));
}
-
+
[Test]
public void EntityService_Can_Get_Paged_Media_Children()
{
@@ -227,7 +227,7 @@ namespace Umbraco.Tests.Services
Assert.That(total, Is.EqualTo(10));
entities = service.GetPagedChildren(root.Id, UmbracoObjectTypes.Media, 1, 6, out total).ToArray();
Assert.That(entities.Length, Is.EqualTo(4));
- Assert.That(total, Is.EqualTo(10));
+ Assert.That(total, Is.EqualTo(10));
}
[Test]
@@ -362,7 +362,7 @@ namespace Umbraco.Tests.Services
var root = MockedMedia.CreateMediaFolder(folderType, -1);
ServiceContext.MediaService.Save(root);
-
+
for (int i = 0; i < 10; i++)
{
var c1 = MockedMedia.CreateMediaImage(imageMediaType, root.Id);
@@ -519,7 +519,7 @@ namespace Umbraco.Tests.Services
Assert.That(
entities.Any(
x =>
- x.AdditionalData.Any(y => y.Value is UmbracoEntity.EntityProperty
+ x.AdditionalData.Any(y => y.Value is UmbracoEntity.EntityProperty
&& ((UmbracoEntity.EntityProperty)y.Value).PropertyEditorAlias == Constants.PropertyEditors.UploadFieldAlias)), Is.True);
}
@@ -575,6 +575,30 @@ namespace Umbraco.Tests.Services
Assert.IsFalse(result2.Success);
}
+ [Test]
+ public void ReserveId()
+ {
+ var service = ServiceContext.EntityService;
+ var guid = Guid.NewGuid();
+
+ // can reserve
+ var reservedId = service.ReserveId(guid);
+ Assert.IsTrue(reservedId > 0);
+
+ // can get it back
+ var id = service.GetIdForKey(guid, UmbracoObjectTypes.DocumentType);
+ Assert.IsTrue(id.Success);
+ Assert.AreEqual(reservedId, id.Result);
+
+ // anything goes
+ id = service.GetIdForKey(guid, UmbracoObjectTypes.Media);
+ Assert.IsTrue(id.Success);
+ Assert.AreEqual(reservedId, id.Result);
+
+ // a random guid won't work
+ Assert.IsFalse(service.GetIdForKey(Guid.NewGuid(), UmbracoObjectTypes.DocumentType).Success);
+ }
+
private static bool _isSetup = false;
private int folderId;
@@ -589,7 +613,7 @@ namespace Umbraco.Tests.Services
//Create and Save folder-Media -> 1050
var folderMediaType = ServiceContext.ContentTypeService.GetMediaType(1031);
- var folder = MockedMedia.CreateMediaFolder(folderMediaType, -1);
+ var folder = MockedMedia.CreateMediaFolder(folderMediaType, -1);
ServiceContext.MediaService.Save(folder, 0);
folderId = folder.Id;
@@ -607,9 +631,9 @@ namespace Umbraco.Tests.Services
ServiceContext.MediaService.Save(subfolder, 0);
var subfolder2 = MockedMedia.CreateMediaFolder(folderMediaType, subfolder.Id);
ServiceContext.MediaService.Save(subfolder2, 0);
-
+
}
-
+
}
}
}
\ No newline at end of file