Moves more services and friends, removes more usages of Current
This commit is contained in:
@@ -10,7 +10,7 @@ namespace Umbraco.Core.Models
|
||||
/// <para>A set of cultures can be either all cultures (including the invariant culture), or
|
||||
/// the invariant culture, or a specific culture.</para>
|
||||
/// </remarks>
|
||||
internal class CultureImpact
|
||||
public sealed class CultureImpact
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility method to return the culture used for invariant property errors based on what cultures are being actively saved,
|
||||
@@ -1,10 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Net.Http;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
|
||||
namespace Umbraco.Core.Services
|
||||
@@ -1,11 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
|
||||
namespace Umbraco.Core.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines part of the MemberService, which is specific to methods used by the membership provider.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Idea is to have this as an isolated interface so that it can be easily 'replaced' in the membership provider implementation.
|
||||
/// </remarks>
|
||||
public interface IMembershipMemberService : IMembershipMemberService<IMember>, IMembershipRoleService<IMember>
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates and persists a new Member
|
||||
/// </summary>
|
||||
/// <param name="username">Username of the Member to create</param>
|
||||
/// <param name="email">Email of the Member to create</param>
|
||||
/// <param name="memberType"><see cref="IMemberType"/> which the Member should be based on</param>
|
||||
/// <returns><see cref="IMember"/></returns>
|
||||
IMember CreateMemberWithIdentity(string username, string email, IMemberType memberType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines part of the UserService/MemberService, which is specific to methods used by the membership provider.
|
||||
/// The generic type is restricted to <see cref="IMembershipUser"/>. The implementation of this interface uses
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Core.Services
|
||||
{
|
||||
public interface IPropertyValidationService
|
||||
{
|
||||
bool IsPropertyDataValid(IContent content, out IProperty[] invalidProperties, CultureImpact impact);
|
||||
bool IsPropertyValid(IProperty property, string culture = "*", string segment = "*");
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core.Collections;
|
||||
using Umbraco.Core.Composing;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Core.Services
|
||||
{
|
||||
//TODO: We should make this an interface and inject it into the ContentService
|
||||
internal class PropertyValidationService
|
||||
internal class PropertyValidationService : IPropertyValidationService
|
||||
{
|
||||
private readonly PropertyEditorCollection _propertyEditors;
|
||||
private readonly IDataTypeService _dataTypeService;
|
||||
@@ -22,12 +15,6 @@ namespace Umbraco.Core.Services
|
||||
_dataTypeService = dataTypeService;
|
||||
}
|
||||
|
||||
//TODO: Remove this method in favor of the overload specifying all dependencies
|
||||
public PropertyValidationService()
|
||||
: this(Current.PropertyEditors, Current.Services.DataTypeService)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the content item's properties pass validation rules
|
||||
/// </summary>
|
||||
@@ -1,27 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
|
||||
namespace Umbraco.Core.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines part of the MemberService, which is specific to methods used by the membership provider.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Idea is to have this as an isolated interface so that it can be easily 'replaced' in the membership provider implementation.
|
||||
/// </remarks>
|
||||
public interface IMembershipMemberService : IMembershipMemberService<IMember>, IMembershipRoleService<IMember>
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates and persists a new Member
|
||||
/// </summary>
|
||||
/// <param name="username">Username of the Member to create</param>
|
||||
/// <param name="email">Email of the Member to create</param>
|
||||
/// <param name="memberType"><see cref="IMemberType"/> which the Member should be based on</param>
|
||||
/// <returns><see cref="IMember"/></returns>
|
||||
IMember CreateMemberWithIdentity(string username, string email, IMemberType memberType);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -27,17 +27,16 @@ namespace Umbraco.Core.Services.Implement
|
||||
private readonly IContentTypeRepository _contentTypeRepository;
|
||||
private readonly IDocumentBlueprintRepository _documentBlueprintRepository;
|
||||
private readonly ILanguageRepository _languageRepository;
|
||||
private readonly IPropertyValidationService _propertyValidationService;
|
||||
private IQuery<IContent> _queryNotTrashed;
|
||||
//TODO: The non-lazy object should be injected
|
||||
private readonly Lazy<PropertyValidationService> _propertyValidationService = new Lazy<PropertyValidationService>(() => new PropertyValidationService());
|
||||
|
||||
|
||||
|
||||
#region Constructors
|
||||
|
||||
public ContentService(IScopeProvider provider, ILogger logger,
|
||||
IEventMessagesFactory eventMessagesFactory,
|
||||
IDocumentRepository documentRepository, IEntityRepository entityRepository, IAuditRepository auditRepository,
|
||||
IContentTypeRepository contentTypeRepository, IDocumentBlueprintRepository documentBlueprintRepository, ILanguageRepository languageRepository)
|
||||
IContentTypeRepository contentTypeRepository, IDocumentBlueprintRepository documentBlueprintRepository, ILanguageRepository languageRepository,
|
||||
IPropertyValidationService propertyValidationService)
|
||||
: base(provider, logger, eventMessagesFactory)
|
||||
{
|
||||
_documentRepository = documentRepository;
|
||||
@@ -46,6 +45,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
_contentTypeRepository = contentTypeRepository;
|
||||
_documentBlueprintRepository = documentBlueprintRepository;
|
||||
_languageRepository = languageRepository;
|
||||
_propertyValidationService = propertyValidationService;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -1404,7 +1404,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
//publish the culture values and validate the property values, if validation fails, log the invalid properties so the develeper has an idea of what has failed
|
||||
IProperty[] invalidProperties = null;
|
||||
var impact = CultureImpact.Explicit(culture, IsDefaultCulture(allLangs, culture));
|
||||
var tryPublish = d.PublishCulture(impact) && _propertyValidationService.Value.IsPropertyDataValid(d, out invalidProperties, impact);
|
||||
var tryPublish = d.PublishCulture(impact) && _propertyValidationService.IsPropertyDataValid(d, out invalidProperties, impact);
|
||||
if (invalidProperties != null && invalidProperties.Length > 0)
|
||||
Logger.Warn<ContentService>("Scheduled publishing will fail for document {DocumentId} and culture {Culture} because of invalid properties {InvalidProperties}",
|
||||
d.Id, culture, string.Join(",", invalidProperties.Select(x => x.Alias)));
|
||||
@@ -1505,12 +1505,12 @@ namespace Umbraco.Core.Services.Implement
|
||||
return culturesToPublish.All(culture =>
|
||||
{
|
||||
var impact = CultureImpact.Create(culture, IsDefaultCulture(allLangs, culture), content);
|
||||
return content.PublishCulture(impact) && _propertyValidationService.Value.IsPropertyDataValid(content, out _, impact);
|
||||
return content.PublishCulture(impact) && _propertyValidationService.IsPropertyDataValid(content, out _, impact);
|
||||
});
|
||||
}
|
||||
|
||||
return content.PublishCulture(CultureImpact.Invariant)
|
||||
&& _propertyValidationService.Value.IsPropertyDataValid(content, out _, CultureImpact.Invariant);
|
||||
&& _propertyValidationService.IsPropertyDataValid(content, out _, CultureImpact.Invariant);
|
||||
}
|
||||
|
||||
// utility 'ShouldPublish' func used by SaveAndPublishBranch
|
||||
@@ -2603,7 +2603,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
//validate the property values
|
||||
IProperty[] invalidProperties = null;
|
||||
if (!impactsToPublish.All(x => _propertyValidationService.Value.IsPropertyDataValid(content, out invalidProperties, x)))
|
||||
if (!impactsToPublish.All(x => _propertyValidationService.IsPropertyDataValid(content, out invalidProperties, x)))
|
||||
return new PublishResult(PublishResultType.FailedPublishContentInvalid, evtMsgs, content)
|
||||
{
|
||||
InvalidProperties = invalidProperties
|
||||
|
||||
@@ -203,7 +203,6 @@
|
||||
<Compile Include="Models\PropertyCollection.cs" />
|
||||
<Compile Include="Models\PropertyType.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\FixLanguageIsoCodeLength.cs" />
|
||||
<Compile Include="Models\CultureImpact.cs" />
|
||||
<Compile Include="Models\PublishedContent\IndexedArrayItem.cs" />
|
||||
<Compile Include="Models\PublishedContent\VariationContextAccessorExtensions.cs" />
|
||||
<Compile Include="Models\Template.cs" />
|
||||
@@ -236,10 +235,7 @@
|
||||
<Compile Include="Serialization\JsonNetSerializer.cs" />
|
||||
<Compile Include="Services\Changes\ContentTypeChange.cs" />
|
||||
<Compile Include="Services\Changes\ContentTypeChangeExtensions.cs" />
|
||||
<Compile Include="Services\IMemberService.cs" />
|
||||
<Compile Include="Services\IMembershipMemberService.cs" />
|
||||
<Compile Include="Services\LocalizedTextServiceExtensions.cs" />
|
||||
<Compile Include="Services\PropertyValidationService.cs" />
|
||||
<Compile Include="StringExtensions.cs" />
|
||||
<Compile Include="Strings\DefaultUrlSegmentProvider.cs" />
|
||||
<Compile Include="Strings\IUrlSegmentProvider.cs" />
|
||||
@@ -651,7 +647,6 @@
|
||||
<Compile Include="Persistence\Querying\SqlExpressionExtensions.cs" />
|
||||
<Compile Include="Persistence\Querying\SqlTranslator.cs" />
|
||||
<Compile Include="Persistence\Querying\TextColumnType.cs" />
|
||||
<Compile Include="Persistence\Querying\ValuePropertyMatchType.cs" />
|
||||
<Compile Include="Persistence\RecordPersistenceType.cs" />
|
||||
<Compile Include="Persistence\Repositories\Implement\AuditRepository.cs" />
|
||||
<Compile Include="Persistence\Repositories\Implement\DocumentBlueprintRepository.cs" />
|
||||
@@ -804,7 +799,6 @@
|
||||
<Compile Include="Services\Implement\RepositoryService.cs" />
|
||||
<Compile Include="Services\Implement\ScopeRepositoryService.cs" />
|
||||
<Compile Include="Services\Implement\ServerRegistrationService.cs" />
|
||||
<Compile Include="Services\ServiceContext.cs" />
|
||||
<Compile Include="Services\Implement\TagService.cs" />
|
||||
<Compile Include="Services\Implement\UserService.cs" />
|
||||
<Compile Include="Services\UserServiceExtensions.cs" />
|
||||
|
||||
Reference in New Issue
Block a user