diff --git a/src/Umbraco.Core/Models/DataTypeDefinition.cs b/src/Umbraco.Core/Models/DataTypeDefinition.cs
index 943bb134d9..6f7fac6db7 100644
--- a/src/Umbraco.Core/Models/DataTypeDefinition.cs
+++ b/src/Umbraco.Core/Models/DataTypeDefinition.cs
@@ -191,10 +191,14 @@ namespace Umbraco.Core.Models
/// Id of the DataType control
///
[DataMember]
- [Obsolete("Property editor's are defined by a string alias from version 7 onwards, use the PropertyEditorAlias property instead")]
+ [Obsolete("Property editor's are defined by a string alias from version 7 onwards, use the PropertyEditorAlias property instead. This method will return a generated GUID for any property editor alias not explicitly mapped to a legacy ID")]
public Guid ControlId
{
- get { return LegacyPropertyEditorIdToAliasConverter.GetLegacyIdFromAlias(_propertyEditorAlias, true).Value; }
+ get
+ {
+ return LegacyPropertyEditorIdToAliasConverter.GetLegacyIdFromAlias(
+ _propertyEditorAlias, LegacyPropertyEditorIdToAliasConverter.NotFoundLegacyIdResponseBehavior.GenerateId).Value;
+ }
set
{
var alias = LegacyPropertyEditorIdToAliasConverter.GetAliasFromLegacyId(value, true);
diff --git a/src/Umbraco.Core/Models/PropertyType.cs b/src/Umbraco.Core/Models/PropertyType.cs
index c5a703df67..c1526a9ffb 100644
--- a/src/Umbraco.Core/Models/PropertyType.cs
+++ b/src/Umbraco.Core/Models/PropertyType.cs
@@ -141,10 +141,14 @@ namespace Umbraco.Core.Models
/// Gets of Sets the Id of the DataType control
///
/// This is the Id of the actual DataType control
- [Obsolete("Property editor's are defined by a string alias from version 7 onwards, use the PropertyEditorAlias property instead")]
+ [Obsolete("Property editor's are defined by a string alias from version 7 onwards, use the PropertyEditorAlias property instead. This method will return a generated GUID for any property editor alias not explicitly mapped to a legacy ID")]
public Guid DataTypeId
{
- get { return LegacyPropertyEditorIdToAliasConverter.GetLegacyIdFromAlias(_propertyEditorAlias, true).Value; }
+ get
+ {
+ return LegacyPropertyEditorIdToAliasConverter.GetLegacyIdFromAlias(
+ _propertyEditorAlias, LegacyPropertyEditorIdToAliasConverter.NotFoundLegacyIdResponseBehavior.GenerateId).Value;
+ }
set
{
var alias = LegacyPropertyEditorIdToAliasConverter.GetAliasFromLegacyId(value, true);
diff --git a/src/Umbraco.Core/PropertyEditors/BackwardsCompatibleData.cs b/src/Umbraco.Core/PropertyEditors/BackwardsCompatibleData.cs
new file mode 100644
index 0000000000..9283256e54
--- /dev/null
+++ b/src/Umbraco.Core/PropertyEditors/BackwardsCompatibleData.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Xml;
+using umbraco.interfaces;
+
+namespace Umbraco.Core.PropertyEditors
+{
+
+ ///
+ /// This is used purelty to attempt to maintain some backwards compatibility with new property editors that don't have a
+ /// legacy property editor predecessor when developers are using the legacy APIs
+ ///
+ internal class BackwardsCompatibleData : IData
+ {
+ public int PropertyId { set; get; }
+
+ public object Value { get; set; }
+
+
+ public XmlNode ToXMl(XmlDocument data)
+ {
+ throw new NotSupportedException(
+ typeof(IData)
+ + " is a legacy object and is not supported by runtime generated "
+ + " instances to maintain backwards compatibility with the legacy APIs. Consider upgrading your code to use the new Services APIs.");
+ }
+
+ public void MakeNew(int PropertyId)
+ {
+ throw new NotSupportedException(
+ typeof(IData)
+ + " is a legacy object and is not supported by runtime generated "
+ + " instances to maintain backwards compatibility with the legacy APIs. Consider upgrading your code to use the new Services APIs.");
+ }
+
+ public void Delete()
+ {
+ throw new NotSupportedException(
+ typeof(IData)
+ + " is a legacy object and is not supported by runtime generated "
+ + " instances to maintain backwards compatibility with the legacy APIs. Consider upgrading your code to use the new Services APIs.");
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/PropertyEditors/BackwardsCompatibleDataType.cs b/src/Umbraco.Core/PropertyEditors/BackwardsCompatibleDataType.cs
new file mode 100644
index 0000000000..0bee6322b3
--- /dev/null
+++ b/src/Umbraco.Core/PropertyEditors/BackwardsCompatibleDataType.cs
@@ -0,0 +1,62 @@
+using System;
+using umbraco.interfaces;
+
+namespace Umbraco.Core.PropertyEditors
+{
+
+ ///
+ /// This is used purelty to attempt to maintain some backwards compatibility with new property editors that don't have a
+ /// legacy property editor predecessor when developers are using the legacy APIs
+ ///
+ internal class BackwardsCompatibleDataType : IDataType
+ {
+ public Guid Id { get; private set; }
+ public string DataTypeName { get; private set; }
+ public IData Data { get; private set; }
+ public int DataTypeDefinitionId { get; set; }
+
+ ///
+ /// Creates a runtime instance
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal static BackwardsCompatibleDataType Create(string propEdAlias, Guid legacyId, int dataTypeDefId)
+ {
+ var dt = new BackwardsCompatibleDataType
+ {
+ Id = legacyId,
+ DataTypeName = propEdAlias,
+ DataTypeDefinitionId = dataTypeDefId,
+ Data = new BackwardsCompatibleData()
+ };
+
+ return dt;
+ }
+
+ public IDataEditor DataEditor
+ {
+ get
+ {
+ throw new NotSupportedException(
+ typeof(IDataEditor)
+ + " is a legacy object and is not supported by runtime generated "
+ + typeof(IDataType)
+ + " instances to maintain backwards compatibility with the legacy APIs. Consider upgrading your code to use the new Services APIs.");
+ }
+ }
+ public IDataPrevalue PrevalueEditor
+ {
+ get
+ {
+ throw new NotSupportedException(
+ typeof(IDataPrevalue)
+ + " is a legacy object and is not supported by runtime generated "
+ + typeof(IDataType)
+ + " instances to maintain backwards compatibility with the legacy APIs. Consider upgrading your code to use the new Services APIs.");
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/PropertyEditors/LegacyPropertyEditorIdToAliasConverter.cs b/src/Umbraco.Core/PropertyEditors/LegacyPropertyEditorIdToAliasConverter.cs
index e36b86b94c..53a4365244 100644
--- a/src/Umbraco.Core/PropertyEditors/LegacyPropertyEditorIdToAliasConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/LegacyPropertyEditorIdToAliasConverter.cs
@@ -3,6 +3,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
using System.Linq;
+using Umbraco.Core.Logging;
namespace Umbraco.Core.PropertyEditors
{
@@ -14,6 +15,14 @@ namespace Umbraco.Core.PropertyEditors
///
public static class LegacyPropertyEditorIdToAliasConverter
{
+
+ public enum NotFoundLegacyIdResponseBehavior
+ {
+ ThrowException,
+ ReturnNull,
+ GenerateId
+ }
+
///
/// The map consists of a key which is always the GUID (lowercase, no hyphens + alias (trimmed))
///
@@ -55,18 +64,27 @@ namespace Umbraco.Core.PropertyEditors
/// Gets a legacy Id based on the alias
///
///
- /// if set to true will throw an exception if the map isn't found
+ ///
/// Returns the legacy GUID of a property editor if found, otherwise returns null
- public static Guid? GetLegacyIdFromAlias(string alias, bool throwIfNotFound = false)
+ public static Guid? GetLegacyIdFromAlias(string alias, NotFoundLegacyIdResponseBehavior notFoundBehavior)
{
var found = _map.FirstOrDefault(x => x.Value.Item2 == alias);
if (found.Equals(default(KeyValuePair>)))
{
- if (throwIfNotFound)
+ switch (notFoundBehavior)
{
- throw new ObjectNotFoundException("Could not find a map for a property editor with an alias of " + alias + ". Consider using the new business logic APIs instead of the old obsoleted ones.");
+ case NotFoundLegacyIdResponseBehavior.ThrowException:
+ throw new ObjectNotFoundException("Could not find a map for a property editor with an alias of " + alias + ". Consider using the new business logic APIs instead of the old obsoleted ones.");
+ case NotFoundLegacyIdResponseBehavior.ReturnNull:
+ return null;
+ case NotFoundLegacyIdResponseBehavior.GenerateId:
+ var generated = alias.EncodeAsGuid();
+ CreateMap(generated, alias);
+
+ LogHelper.Warn(typeof(LegacyPropertyEditorIdToAliasConverter), "A legacy GUID id was generated for property editor " + alias + ". This occurs when the legacy APIs are used and done to attempt to maintain backwards compatibility. Consider upgrading all code to use the new Services APIs instead to avoid any potential issues.");
+
+ return generated;
}
- return null;
}
return found.Value.Item1;
}
diff --git a/src/Umbraco.Core/PublishedContentHelper.cs b/src/Umbraco.Core/PublishedContentHelper.cs
index a6a3c1cadc..1707f0f745 100644
--- a/src/Umbraco.Core/PublishedContentHelper.cs
+++ b/src/Umbraco.Core/PublishedContentHelper.cs
@@ -113,16 +113,16 @@ namespace Umbraco.Core
//if it is good return it, otherwise we'll continue processing the legacy stuff below.
if (result.Success)
{
- return new Attempt