Merge remote-tracking branch 'origin/6.2.0' into 7.1.0

Conflicts:
	src/Umbraco.Web.UI/umbraco/create/simple.ascx
	src/Umbraco.Web.UI/umbraco/developer/DataTypes/editDatatype.aspx
	src/Umbraco.Web/Umbraco.Web.csproj
	src/Umbraco.Web/umbraco.presentation/umbraco/create/nodeType.ascx.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/developer/DataTypes/editDatatype.aspx.cs
	src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs
This commit is contained in:
Shannon
2014-03-10 17:30:46 +11:00
15 changed files with 133 additions and 58 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
@@ -11,6 +12,7 @@ using Umbraco.Core.Persistence.Caching;
using Umbraco.Core.Persistence.Factories;
using Umbraco.Core.Persistence.Querying;
using Umbraco.Core.Persistence.Relators;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.Persistence.UnitOfWork;
namespace Umbraco.Core.Persistence.Repositories
@@ -63,6 +65,17 @@ namespace Umbraco.Core.Persistence.Repositories
protected void PersistNewBaseContentType(ContentTypeDto dto, IContentTypeComposition entity)
{
//Cannot add a duplicate content type type
var exists = Database.ExecuteScalar<int>(@"SELECT COUNT(*) FROM cmsContentType
INNER JOIN umbracoNode ON cmsContentType.nodeId = umbracoNode.id
WHERE cmsContentType." + SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName("alias") + @"= @alias
AND umbracoNode.nodeObjectType = @objectType",
new { alias = entity.Alias, objectType = NodeObjectTypeId });
if (exists > 0)
{
throw new DuplicateNameException("An item with the alias " + entity.Alias + " already exists");
}
//Logic for setting Path, Level and SortOrder
var parent = Database.First<NodeDto>("WHERE id = @ParentId", new { ParentId = entity.ParentId });
int level = parent.Level + 1;
@@ -165,6 +178,19 @@ namespace Umbraco.Core.Persistence.Repositories
protected void PersistUpdatedBaseContentType(ContentTypeDto dto, IContentTypeComposition entity)
{
//Cannot update to a duplicate alias
var exists = Database.ExecuteScalar<int>(@"SELECT COUNT(*) FROM cmsContentType
INNER JOIN umbracoNode ON cmsContentType.nodeId = umbracoNode.id
WHERE cmsContentType." + SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName("alias") + @"= @alias
AND umbracoNode.nodeObjectType = @objectType
AND umbracoNode.id <> @id",
new { id = dto.NodeId, alias = entity.Alias, objectType = NodeObjectTypeId });
if (exists > 0)
{
throw new DuplicateNameException("An item with the alias " + entity.Alias + " already exists");
}
var propertyGroupFactory = new PropertyGroupFactory(entity.Id);
var nodeDto = dto.NodeDto;

View File

@@ -165,6 +165,18 @@ WHERE umbracoNode." + SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName("te
protected override void PersistUpdatedItem(IDataTypeDefinition entity)
{
//Cannot change to a duplicate alias
var exists = Database.ExecuteScalar<int>(@"SELECT COUNT(*) FROM cmsDataType
INNER JOIN umbracoNode ON cmsDataType.nodeId = umbracoNode.id
WHERE umbracoNode." + SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName("text") + @"= @name
AND umbracoNode.id <> @id",
new { id = entity.Id, name = entity.Name });
if (exists > 0)
{
throw new DuplicateNameException("A data type with the name " + entity.Name + " already exists");
}
//Updates Modified date and Version Guid
((DataTypeDefinition)entity).UpdatingEntity();

View File

@@ -223,8 +223,19 @@ namespace Umbraco.Core.Persistence.Repositories
/// <param name="entity"></param>
public virtual void PersistNewItem(IEntity entity)
{
PersistNewItem((TEntity)entity);
_cache.Save(typeof(TEntity), entity);
try
{
PersistNewItem((TEntity)entity);
_cache.Save(typeof(TEntity), entity);
}
catch (Exception)
{
//if an exception is thrown we need to remove the entry from cache, this is ONLY a work around because of the way
// that we cache entities: http://issues.umbraco.org/issue/U4-4259
_cache.Delete(typeof (TEntity), entity);
throw;
}
}
/// <summary>
@@ -233,8 +244,19 @@ namespace Umbraco.Core.Persistence.Repositories
/// <param name="entity"></param>
public virtual void PersistUpdatedItem(IEntity entity)
{
PersistUpdatedItem((TEntity)entity);
_cache.Save(typeof(TEntity), entity);
try
{
PersistUpdatedItem((TEntity)entity);
_cache.Save(typeof(TEntity), entity);
}
catch (Exception)
{
//if an exception is thrown we need to remove the entry from cache, this is ONLY a work around because of the way
// that we cache entities: http://issues.umbraco.org/issue/U4-4259
_cache.Delete(typeof (TEntity), entity);
throw;
}
}
/// <summary>