Gets validation working with composition alias conflicts

This commit is contained in:
Shannon
2015-10-09 19:03:11 +02:00
parent 6017e9ddf9
commit 2922e962e0
7 changed files with 114 additions and 30 deletions

View File

@@ -3,22 +3,41 @@
namespace Umbraco.Core.Exceptions
{
public class InvalidCompositionException : Exception
{
public string ContentTypeAlias { get; set; }
{
public InvalidCompositionException(string contentTypeAlias, string addedCompositionAlias, string[] propertyTypeAliass)
{
ContentTypeAlias = contentTypeAlias;
AddedCompositionAlias = addedCompositionAlias;
PropertyTypeAliases = propertyTypeAliass;
}
public string AddedCompositionAlias { get; set; }
public InvalidCompositionException(string contentTypeAlias, string[] propertyTypeAliass)
{
ContentTypeAlias = contentTypeAlias;
PropertyTypeAliases = propertyTypeAliass;
}
public string PropertyTypeAlias { get; set; }
public string ContentTypeAlias { get; private set; }
public string AddedCompositionAlias { get; private set; }
public string[] PropertyTypeAliases { get; private set; }
public override string Message
{
get
{
return string.Format(
"InvalidCompositionException - ContentType with alias '{0}' was added as a Compsition to ContentType with alias '{1}', " +
"but there was a conflict on the PropertyType alias '{2}'. " +
return AddedCompositionAlias.IsNullOrWhiteSpace()
? string.Format(
"ContentType with alias '{0}' has an invalid composition " +
"and there was a conflict on the following PropertyTypes: '{1}'. " +
"PropertyTypes must have a unique alias across all Compositions in order to compose a valid ContentType Composition.",
AddedCompositionAlias, ContentTypeAlias, PropertyTypeAlias);
ContentTypeAlias, string.Join(", ", PropertyTypeAliases))
: string.Format(
"ContentType with alias '{0}' was added as a Composition to ContentType with alias '{1}', " +
"but there was a conflict on the following PropertyTypes: '{2}'. " +
"PropertyTypes must have a unique alias across all Compositions in order to compose a valid ContentType Composition.",
AddedCompositionAlias, ContentTypeAlias, string.Join(", ", PropertyTypeAliases));
}
}
}