Merge remote-tracking branch 'origin/7.3.0' into dev-v8

Conflicts:
	src/Umbraco.Core/Services/ServiceContext.cs
	src/Umbraco.Core/Umbraco.Core.csproj
	src/Umbraco.Tests/Mvc/UmbracoViewPageTests.cs
	src/Umbraco.Tests/Persistence/BaseTableByTableTest.cs
	src/Umbraco.Tests/TestHelpers/BaseUmbracoApplicationTest.cs
This commit is contained in:
Shannon
2015-01-27 15:00:23 +11:00
22 changed files with 200 additions and 74 deletions

View File

@@ -229,7 +229,7 @@ namespace Umbraco.Core
if (currentVersion != configStatus)
{
ProfilingLogger.Logger.Info<ApplicationContext>("CurrentVersion different from configStatus: '" + currentVersion + "','" + configStatus + "'");
ProfilingLogger.Logger.Debug<ApplicationContext>("CurrentVersion different from configStatus: '" + currentVersion + "','" + configStatus + "'");
}

View File

@@ -0,0 +1,27 @@
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.DatabaseAnnotations;
namespace Umbraco.Core.Models.Rdbms
{
[TableName("umbracoAccess")]
[PrimaryKey("id")]
[ExplicitColumns]
internal class AccessDto
{
[Column("id")]
[PrimaryKeyColumn(Name = "PK_umbracoAccess")]
public int Id { get; set; }
[Column("nodeId")]
[ForeignKey(typeof(NodeDto), Name = "FK_umbracoAccess_umbracoNode_id")]
public int NodeId { get; set; }
[Column("loginNodeId")]
[ForeignKey(typeof(NodeDto), Name = "FK_umbracoAccess_umbracoNode_id1")]
public int LoginNodeId { get; set; }
[Column("noAccessNodeId")]
[ForeignKey(typeof(NodeDto), Name = "FK_umbracoAccess_umbracoNode_id2")]
public int AccessDeniedNodeId { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.DatabaseAnnotations;
namespace Umbraco.Core.Models.Rdbms
{
[TableName("umbracoAccessRule")]
[PrimaryKey("id")]
[ExplicitColumns]
internal class AccessRuleDto
{
[Column("id")]
[PrimaryKeyColumn(Name = "PK_umbracoAccessRule")]
public int Id { get; set; }
[Column("accessId")]
[ForeignKey(typeof(AccessDto), Name = "FK_umbracoAccessRule_umbracoAccess_id")]
public int AccessId { get; set; }
[Column("claim")]
public string Claim { get; set; }
[Column("claimType")]
public string ClaimType { get; set; }
}
}

View File

@@ -26,11 +26,6 @@ namespace Umbraco.Core.Models.Rdbms
[Constraint(Default = "getdate()")]
public DateTime VersionDate { get; set; }
[Column("LanguageLocale")]
[Length(10)]
[NullSetting(NullSetting = NullSettings.Null)]
public string Language { get; set; }
[ResultColumn]
public ContentDto ContentDto { get; set; }
}

View File

@@ -38,7 +38,6 @@ namespace Umbraco.Core.Persistence.Factories
: _id.ToGuid(),
Name = dto.Text,
NodeName = dto.ContentVersionDto.ContentDto.NodeDto.Text,
Language = dto.ContentVersionDto.Language,
Path = dto.ContentVersionDto.ContentDto.NodeDto.Path,
CreatorId = dto.ContentVersionDto.ContentDto.NodeDto.UserId.Value,
WriterId = dto.WriterUserId,
@@ -107,7 +106,6 @@ namespace Umbraco.Core.Persistence.Factories
NodeId = entity.Id,
VersionDate = entity.UpdateDate,
VersionId = entity.Version,
Language = lang,
ContentDto = BuildContentDto(entity)
};
return contentVersionDto;

View File

@@ -47,7 +47,6 @@ namespace Umbraco.Core.Persistence.Mappers
CacheMap<Content, ContentDto>(src => src.ContentTypeId, dto => dto.ContentTypeId);
CacheMap<Content, ContentVersionDto>(src => src.UpdateDate, dto => dto.VersionDate);
CacheMap<Content, ContentVersionDto>(src => src.Version, dto => dto.VersionId);
CacheMap<Content, ContentVersionDto>(src => src.Language, dto => dto.Language);
CacheMap<Content, DocumentDto>(src => src.Name, dto => dto.Text);
CacheMap<Content, DocumentDto>(src => src.ExpireDate, dto => dto.ExpiresDate);
CacheMap<Content, DocumentDto>(src => src.ReleaseDate, dto => dto.ReleaseDate);

View File

@@ -78,7 +78,10 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
{37, typeof (User2AppDto)},
{38, typeof (User2NodeNotifyDto)},
{39, typeof (User2NodePermissionDto)},
{40, typeof (ServerRegistrationDto)}
{40, typeof (ServerRegistrationDto)},
{41, typeof (AccessDto)},
{42, typeof (AccessRuleDto)}
};
#endregion

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
using Umbraco.Core.Persistence.SqlSyntax;
@@ -6,12 +7,27 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Create.Expressions
{
public class CreateTableExpression : MigrationExpressionBase
{
[Obsolete("Use the other constructors specifying an ISqlSyntaxProvider instead")]
public CreateTableExpression()
{
Columns = new List<ColumnDefinition>();
}
public CreateTableExpression(DatabaseProviders current, DatabaseProviders[] databaseProviders) : base(current, databaseProviders)
[Obsolete("Use the other constructors specifying an ISqlSyntaxProvider instead")]
public CreateTableExpression(DatabaseProviders current, DatabaseProviders[] databaseProviders)
: base(current, databaseProviders)
{
Columns = new List<ColumnDefinition>();
}
public CreateTableExpression(ISqlSyntaxProvider sqlSyntax)
: base(sqlSyntax)
{
Columns = new List<ColumnDefinition>();
}
public CreateTableExpression(DatabaseProviders current, DatabaseProviders[] databaseProviders, ISqlSyntaxProvider sqlSyntax)
: base(current, databaseProviders, sqlSyntax)
{
Columns = new List<ColumnDefinition>();
}
@@ -22,9 +38,9 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Create.Expressions
public override string ToString()
{
var table = new TableDefinition{Name = TableName, SchemaName = SchemaName, Columns = Columns};
var table = new TableDefinition { Name = TableName, SchemaName = SchemaName, Columns = Columns };
return string.Format(SqlSyntaxContext.SqlSyntaxProvider.Format(table));
return string.Format(SqlSyntax.Format(table));
}
}
}

View File

@@ -85,6 +85,17 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Create.Table
public ICreateTableColumnOptionSyntax PrimaryKey()
{
CurrentColumn.IsPrimaryKey = true;
var expression = new CreateConstraintExpression(ConstraintType.PrimaryKey)
{
Constraint =
{
TableName = CurrentColumn.TableName,
Columns = new[] { CurrentColumn.Name }
}
};
_context.Expressions.Add(expression);
return this;
}
@@ -92,6 +103,18 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Create.Table
{
CurrentColumn.IsPrimaryKey = true;
CurrentColumn.PrimaryKeyName = primaryKeyName;
var expression = new CreateConstraintExpression(ConstraintType.PrimaryKey)
{
Constraint =
{
ConstraintName = primaryKeyName,
TableName = CurrentColumn.TableName,
Columns = new[] { CurrentColumn.Name }
}
};
_context.Expressions.Add(expression);
return this;
}

View File

@@ -0,0 +1,36 @@
using System.Linq;
using Umbraco.Core.Configuration;
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenThreeZero
{
[Migration("7.3.0", 5, GlobalSettings.UmbracoMigrationName)]
public class AddPublicAccessTables : MigrationBase
{
public override void Up()
{
//Don't exeucte if the table is already there
var tables = SqlSyntax.GetTablesInSchema(Context.Database).ToArray();
if (tables.InvariantContains("umbracoAccess")) return;
Create.Table("umbracoAccess")
.WithColumn("id").AsInt32().NotNullable().Identity().PrimaryKey("PK_umbracoAccess")
.WithColumn("nodeId").AsInt32().NotNullable().ForeignKey("FK_umbracoAccess_umbracoNode_id", "umbracoNode", "id")
.WithColumn("loginNodeId").AsInt32().NotNullable().ForeignKey("FK_umbracoAccess_umbracoNode_id1", "umbracoNode", "id")
.WithColumn("noAccessNodeId").AsInt32().NotNullable().ForeignKey("FK_umbracoAccess_umbracoNode_id2", "umbracoNode", "id");
Create.Table("umbracoAccessRule")
.WithColumn("id").AsInt32().NotNullable().Identity().PrimaryKey("PK_umbracoAccessRule")
.WithColumn("accessId").AsInt32().NotNullable().ForeignKey("FK_umbracoAccessRule_umbracoAccess_id", "umbracoAccess", "id")
.WithColumn("claim").AsString().NotNullable()
.WithColumn("claimType").AsString().NotNullable();
//Create.PrimaryKey("PK_cmsContentType2ContentType")
// .OnTable("cmsContentType2ContentType")
// .Columns(new[] { "parentContentTypeId", "childContentTypeId" });
}
public override void Down()
{
}
}
}

View File

@@ -23,6 +23,10 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenThreeZe
{
public override void Up()
{
//Don't exeucte if the stylesheet table is not there
var tables = SqlSyntax.GetTablesInSchema(Context.Database).ToArray();
if (tables.InvariantContains("cmsStylesheet") == false) return;
//This is all rather nasty but it's how stylesheets used to work in the 2 various ugly ways so we just have to
// deal with that to get this migration done

View File

@@ -0,0 +1,23 @@
using System.Linq;
using Umbraco.Core.Configuration;
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenThreeZero
{
[Migration("7.3.0", 4, GlobalSettings.UmbracoMigrationName)]
public class RemoveLanguageLocaleColumn : MigrationBase
{
public override void Up()
{
var columns = SqlSyntax.GetColumnsInSchema(Context.Database).Distinct().ToArray();
if (columns.Any(x => x.ColumnName.InvariantEquals("LanguageLocale") && x.TableName.InvariantEquals("cmsContentVersion")))
{
Delete.Column("LanguageLocale").FromTable("cmsContentVersion");
}
}
public override void Down()
{
}
}
}

View File

@@ -629,21 +629,6 @@ namespace Umbraco.Core.Persistence.Repositories
}
}
public IContent GetByLanguage(int id, string language)
{
var sql = GetBaseQuery(false);
sql.Where(GetBaseWhereClause(), new { Id = id });
sql.Where<ContentVersionDto>(x => x.Language == language);
sql.OrderByDescending<ContentVersionDto>(x => x.VersionDate);
var dto = Database.Fetch<DocumentDto, ContentVersionDto, ContentDto, NodeDto>(sql).FirstOrDefault();
if (dto == null)
return null;
return GetByVersion(dto.ContentVersionDto.VersionId);
}
/// <summary>
/// Assigns a single permission to the current content item for the specified user ids
/// </summary>

View File

@@ -33,14 +33,6 @@ namespace Umbraco.Core.Persistence.Repositories
/// <param name="content"></param>
void ClearPublished(IContent content);
/// <summary>
/// Gets a specific language version of an <see cref="IContent"/>
/// </summary>
/// <param name="id">Id of the <see cref="IContent"/> to retrieve version from</param>
/// <param name="language">Culture code for the language to retrieve</param>
/// <returns>An <see cref="IContent"/> item</returns>
IContent GetByLanguage(int id, string language);
/// <summary>
/// Gets all published Content by the specified query
/// </summary>

View File

@@ -306,6 +306,8 @@
<Compile Include="Models\AuditType.cs" />
<Compile Include="ObjectResolution\ContainerLazyManyObjectsResolver.cs" />
<Compile Include="ObjectResolution\ContainerManyObjectsResolver.cs" />
<Compile Include="Models\Rdbms\AccessDto.cs" />
<Compile Include="Models\Rdbms\AccessRuleDto.cs" />
<Compile Include="ObjectResolution\ContainerSingleObjectResolver.cs" />
<Compile Include="Models\UmbracoDomain.cs" />
<Compile Include="Models\DoNotCloneAttribute.cs" />
@@ -313,6 +315,8 @@
<Compile Include="Persistence\Factories\TaskFactory.cs" />
<Compile Include="Persistence\Factories\TaskTypeFactory.cs" />
<Compile Include="Persistence\Mappers\DomainMapper.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenThreeZero\AddPublicAccessTables.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenThreeZero\RemoveLanguageLocaleColumn.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenThreeZero\RemoveStylesheetDataAndTables.cs" />
<Compile Include="Persistence\Repositories\AuditRepository.cs" />
<Compile Include="Persistence\Repositories\DomainRepository.cs" />

View File

@@ -62,7 +62,7 @@ namespace Umbraco.Tests.Persistence
//assign the service context
new ServiceContext(repositoryFactory, new PetaPocoUnitOfWorkProvider(_logger), new FileUnitOfWorkProvider(), new PublishingStrategy(), cacheHelper, _logger, new[] { new DefaultUrlSegmentProvider() }),
cacheHelper,
new ProfilingLogger(new Logger(new FileInfo(TestHelper.MapPathForTest("~/unit-test-log4net.config"))), Mock.Of<IProfiler>()))
new ProfilingLogger(_logger, Mock.Of<IProfiler>()))
{
IsReady = true
};
@@ -95,6 +95,31 @@ namespace Umbraco.Tests.Persistence
}
}
[Test]
public void Can_Create_umbracoAccess_Table()
{
using (Transaction transaction = Database.GetTransaction())
{
DatabaseSchemaHelper.CreateTable<NodeDto>();
DatabaseSchemaHelper.CreateTable<AccessDto>();
//transaction.Complete();
}
}
[Test]
public void Can_Create_umbracoAccessRule_Table()
{
using (Transaction transaction = Database.GetTransaction())
{
DatabaseSchemaHelper.CreateTable<NodeDto>();
DatabaseSchemaHelper.CreateTable<AccessDto>();
DatabaseSchemaHelper.CreateTable<AccessRuleDto>();
//transaction.Complete();
}
}
[Test]
public void Can_Create_cmsContentType2ContentType_Table()
{

View File

@@ -678,34 +678,6 @@ namespace Umbraco.Tests.Persistence.Repositories
}
[Test]
public void Can_Create_Different_Language_Version()
{
// Arrange
var provider = new PetaPocoUnitOfWorkProvider(Logger);
var unitOfWork = provider.GetUnitOfWork();
ContentTypeRepository contentTypeRepository;
using (var repository = CreateRepository(unitOfWork, out contentTypeRepository))
{
var content = repository.Get(NodeDto.NodeIdSeed + 2);
// Act
content.Language = "da-DK";
content.Name = "Tekst Side 1";
repository.AddOrUpdate(content);
unitOfWork.Commit();
var latest = repository.Get(NodeDto.NodeIdSeed + 2);
var english = repository.GetByLanguage(NodeDto.NodeIdSeed + 2, "en-US");
var danish = repository.GetByLanguage(NodeDto.NodeIdSeed + 2, "da-DK");
// Assert
Assert.That(latest.Name, Is.EqualTo("Tekst Side 1"));
Assert.That(english.Name, Is.EqualTo("Text Page 1"));
Assert.That(danish.Name, Is.EqualTo("Tekst Side 1"));
}
}
public void CreateTestData()
{
//Create and Save ContentType "umbTextpage" -> (NodeDto.NodeIdSeed)

View File

@@ -7,8 +7,6 @@ using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Querying;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Persistence.UnitOfWork;

View File

@@ -389,7 +389,7 @@ namespace Umbraco.Tests.Persistence.Repositories
var sql = new Sql();
sql.Select("umbracoNode.*", "cmsContent.contentType", "cmsContentType.alias AS ContentTypeAlias", "cmsContentVersion.VersionId",
"cmsContentVersion.VersionDate", "cmsContentVersion.LanguageLocale", "cmsMember.Email",
"cmsContentVersion.VersionDate", "cmsMember.Email",
"cmsMember.LoginName", "cmsMember.Password", "cmsPropertyData.id AS PropertyDataId", "cmsPropertyData.propertytypeid",
"cmsPropertyData.dataDate", "cmsPropertyData.dataInt", "cmsPropertyData.dataNtext", "cmsPropertyData.dataNvarchar",
"cmsPropertyType.id", "cmsPropertyType.Alias", "cmsPropertyType.Description",

View File

@@ -140,13 +140,15 @@ namespace Umbraco.Tests.Routing
[Test]
public void Get_Nice_Url_Relative_Or_Absolute()
{
var routingContext = GetRoutingContext("http://example.com/test", 1111);
SettingsForTests.UseDirectoryUrls = true;
SettingsForTests.HideTopLevelNodeFromPath = false;
var requestMock = Mock.Get(_umbracoSettings.RequestHandler);
requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);
var routingContext = GetRoutingContext("http://example.com/test", 1111, umbracoSettings: _umbracoSettings);
Assert.AreEqual("/home/sub1/custom-sub-1/", routingContext.UrlProvider.GetUrl(1177));
requestMock.Setup(x => x.UseDomainPrefixes).Returns(true);

View File

@@ -11,6 +11,7 @@ using Umbraco.Core.IO;
namespace umbraco.cms.businesslogic.translation
{
[Obsolete("This will be removed in future versions, the translation utility will not work perfectly in v7.x")]
public class Translation
{
public static void MakeNew(CMSNode Node, User User, User Translator, Language Language, string Comment,

View File

@@ -382,9 +382,7 @@
<LastGenOutput>PackageFiles.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Folder Include="businesslogic\translate\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>