2013-09-13 18:11:20 +10:00
|
|
|
using Umbraco.Core.Configuration;
|
2014-01-28 10:46:59 +11:00
|
|
|
using System;
|
2013-09-13 18:11:20 +10:00
|
|
|
using Umbraco.Core.Configuration.UmbracoSettings;
|
2015-01-09 10:51:15 +11:00
|
|
|
using Umbraco.Core.IO;
|
|
|
|
|
using Umbraco.Core.Logging;
|
2015-01-13 13:33:39 +11:00
|
|
|
|
2012-12-09 09:01:00 +05:00
|
|
|
using Umbraco.Core.Persistence.Repositories;
|
2015-01-13 13:25:36 +11:00
|
|
|
using Umbraco.Core.Persistence.SqlSyntax;
|
2012-12-09 09:01:00 +05:00
|
|
|
using Umbraco.Core.Persistence.UnitOfWork;
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Core.Persistence
|
|
|
|
|
{
|
2012-12-10 08:44:17 -01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Used to instantiate each repository type
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class RepositoryFactory
|
|
|
|
|
{
|
2015-01-09 10:51:15 +11:00
|
|
|
private readonly ILogger _logger;
|
2015-01-13 13:25:36 +11:00
|
|
|
private readonly ISqlSyntaxProvider _sqlSyntax;
|
2014-01-28 10:46:59 +11:00
|
|
|
private readonly CacheHelper _cacheHelper;
|
2013-09-16 17:39:45 +10:00
|
|
|
private readonly IUmbracoSettingsSection _settings;
|
2013-09-13 18:11:20 +10:00
|
|
|
|
2014-02-13 16:56:23 +11:00
|
|
|
#region Ctors
|
2015-01-09 10:51:15 +11:00
|
|
|
|
2015-01-13 13:25:36 +11:00
|
|
|
public RepositoryFactory(CacheHelper cacheHelper, ILogger logger, ISqlSyntaxProvider sqlSyntax, IUmbracoSettingsSection settings)
|
2015-01-09 10:51:15 +11:00
|
|
|
{
|
|
|
|
|
if (cacheHelper == null) throw new ArgumentNullException("cacheHelper");
|
|
|
|
|
if (logger == null) throw new ArgumentNullException("logger");
|
2015-01-13 19:38:23 +11:00
|
|
|
//if (sqlSyntax == null) throw new ArgumentNullException("sqlSyntax");
|
2015-01-09 10:51:15 +11:00
|
|
|
if (settings == null) throw new ArgumentNullException("settings");
|
|
|
|
|
|
2015-01-13 13:25:36 +11:00
|
|
|
_cacheHelper = cacheHelper;
|
2015-01-09 10:51:15 +11:00
|
|
|
_logger = logger;
|
2015-01-13 13:25:36 +11:00
|
|
|
_sqlSyntax = sqlSyntax;
|
2015-01-09 10:51:15 +11:00
|
|
|
_settings = settings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Obsolete("Use the ctor specifying all dependencies instead")]
|
2013-09-18 12:54:06 +10:00
|
|
|
public RepositoryFactory()
|
2015-01-13 13:25:36 +11:00
|
|
|
: this(ApplicationContext.Current.ApplicationCache, LoggerResolver.Current.Logger, SqlSyntaxContext.SqlSyntaxProvider, UmbracoConfig.For.UmbracoSettings())
|
2013-09-13 18:11:20 +10:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-13 13:25:36 +11:00
|
|
|
[Obsolete("Use the ctor specifying all dependencies instead")]
|
2014-01-28 10:46:59 +11:00
|
|
|
public RepositoryFactory(CacheHelper cacheHelper)
|
2015-01-13 13:25:36 +11:00
|
|
|
: this(cacheHelper, LoggerResolver.Current.Logger, SqlSyntaxContext.SqlSyntaxProvider, UmbracoConfig.For.UmbracoSettings())
|
2014-01-28 10:46:59 +11:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-13 13:25:36 +11:00
|
|
|
[Obsolete("Use the ctor specifying all dependencies instead, NOTE: disableAllCache has zero effect")]
|
2014-01-28 10:46:59 +11:00
|
|
|
public RepositoryFactory(bool disableAllCache, CacheHelper cacheHelper)
|
2015-01-13 13:25:36 +11:00
|
|
|
: this(cacheHelper, LoggerResolver.Current.Logger, SqlSyntaxContext.SqlSyntaxProvider, UmbracoConfig.For.UmbracoSettings())
|
2014-01-28 10:46:59 +11:00
|
|
|
{
|
|
|
|
|
if (cacheHelper == null) throw new ArgumentNullException("cacheHelper");
|
|
|
|
|
_cacheHelper = cacheHelper;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-13 13:25:36 +11:00
|
|
|
[Obsolete("Use the ctor specifying all dependencies instead")]
|
2013-10-09 13:17:19 +11:00
|
|
|
public RepositoryFactory(bool disableAllCache)
|
2015-01-13 13:25:36 +11:00
|
|
|
: this(disableAllCache ? CacheHelper.CreateDisabledCacheHelper() : ApplicationContext.Current.ApplicationCache, LoggerResolver.Current.Logger, SqlSyntaxContext.SqlSyntaxProvider, UmbracoConfig.For.UmbracoSettings())
|
2013-09-18 13:26:09 +10:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-09 10:51:15 +11:00
|
|
|
|
2014-02-13 16:56:23 +11:00
|
|
|
#endregion
|
|
|
|
|
|
2015-01-28 13:16:50 +11:00
|
|
|
public virtual IPublicAccessRepository CreatePublicAccessRepository(IDatabaseUnitOfWork uow)
|
|
|
|
|
{
|
|
|
|
|
return new PublicAccessRepository(uow,
|
|
|
|
|
_cacheHelper,
|
|
|
|
|
_logger, _sqlSyntax);
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-19 18:37:48 +11:00
|
|
|
public virtual ITaskRepository CreateTaskRepository(IDatabaseUnitOfWork uow)
|
|
|
|
|
{
|
2015-01-22 19:19:21 +11:00
|
|
|
return new TaskRepository(uow,
|
|
|
|
|
CacheHelper.CreateDisabledCacheHelper(), //never cache
|
|
|
|
|
_logger, _sqlSyntax);
|
2015-01-19 18:37:48 +11:00
|
|
|
}
|
|
|
|
|
|
2015-01-19 15:12:34 +11:00
|
|
|
public virtual IAuditRepository CreateAuditRepository(IDatabaseUnitOfWork uow)
|
|
|
|
|
{
|
|
|
|
|
return new AuditRepository(uow, _cacheHelper, _logger, _sqlSyntax);
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-01 18:06:24 +10:00
|
|
|
public virtual ITagRepository CreateTagRepository(IDatabaseUnitOfWork uow)
|
2013-10-04 16:11:51 +10:00
|
|
|
{
|
2014-09-01 18:06:24 +10:00
|
|
|
return new TagRepository(
|
2013-10-04 16:11:51 +10:00
|
|
|
uow,
|
2015-01-13 19:38:23 +11:00
|
|
|
_cacheHelper, _logger, _sqlSyntax);
|
2013-10-04 16:11:51 +10:00
|
|
|
}
|
2013-09-18 12:54:06 +10:00
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IContentRepository CreateContentRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new ContentRepository(
|
2015-01-13 13:25:36 +11:00
|
|
|
uow,
|
|
|
|
|
_cacheHelper,
|
2015-01-09 10:51:15 +11:00
|
|
|
_logger,
|
2015-01-13 19:38:23 +11:00
|
|
|
_sqlSyntax,
|
2012-12-10 08:44:17 -01:00
|
|
|
CreateContentTypeRepository(uow),
|
2013-10-04 17:13:57 +10:00
|
|
|
CreateTemplateRepository(uow),
|
2015-01-13 18:19:52 +11:00
|
|
|
CreateTagRepository(uow))
|
|
|
|
|
{
|
|
|
|
|
EnsureUniqueNaming = _settings.Content.EnsureUniqueNaming
|
|
|
|
|
};
|
2012-12-10 08:44:17 -01:00
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IContentTypeRepository CreateContentTypeRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new ContentTypeRepository(
|
|
|
|
|
uow,
|
2015-01-13 13:25:36 +11:00
|
|
|
_cacheHelper,
|
2015-01-13 19:38:23 +11:00
|
|
|
_logger, _sqlSyntax,
|
2014-04-17 14:23:37 +10:00
|
|
|
CreateTemplateRepository(uow));
|
2012-12-10 08:44:17 -01:00
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IDataTypeDefinitionRepository CreateDataTypeDefinitionRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new DataTypeDefinitionRepository(
|
|
|
|
|
uow,
|
2015-01-13 13:25:36 +11:00
|
|
|
_cacheHelper,
|
2014-04-17 18:03:34 +10:00
|
|
|
_cacheHelper,
|
2015-01-13 19:38:23 +11:00
|
|
|
_logger, _sqlSyntax,
|
2014-04-17 18:03:34 +10:00
|
|
|
CreateContentTypeRepository(uow));
|
2012-12-10 08:44:17 -01:00
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IDictionaryRepository CreateDictionaryRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new DictionaryRepository(
|
|
|
|
|
uow,
|
2015-01-13 13:25:36 +11:00
|
|
|
_cacheHelper,
|
2015-01-09 10:51:15 +11:00
|
|
|
_logger,
|
2015-01-13 13:25:36 +11:00
|
|
|
_sqlSyntax,
|
2012-12-10 08:44:17 -01:00
|
|
|
CreateLanguageRepository(uow));
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual ILanguageRepository CreateLanguageRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new LanguageRepository(
|
|
|
|
|
uow,
|
2015-01-13 13:25:36 +11:00
|
|
|
_cacheHelper,
|
2015-01-13 19:38:23 +11:00
|
|
|
_logger, _sqlSyntax);
|
2012-12-10 08:44:17 -01:00
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IMediaRepository CreateMediaRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new MediaRepository(
|
|
|
|
|
uow,
|
2015-01-13 13:25:36 +11:00
|
|
|
_cacheHelper,
|
2015-01-13 19:38:23 +11:00
|
|
|
_logger, _sqlSyntax,
|
2013-10-08 12:25:03 +11:00
|
|
|
CreateMediaTypeRepository(uow),
|
2014-09-01 18:06:24 +10:00
|
|
|
CreateTagRepository(uow)) { EnsureUniqueNaming = _settings.Content.EnsureUniqueNaming };
|
2012-12-10 08:44:17 -01:00
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IMediaTypeRepository CreateMediaTypeRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new MediaTypeRepository(
|
|
|
|
|
uow,
|
2015-01-13 13:25:36 +11:00
|
|
|
_cacheHelper,
|
2015-01-13 19:38:23 +11:00
|
|
|
_logger, _sqlSyntax);
|
2012-12-10 08:44:17 -01:00
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IRelationRepository CreateRelationRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new RelationRepository(
|
|
|
|
|
uow,
|
2015-01-13 13:25:36 +11:00
|
|
|
CacheHelper.CreateDisabledCacheHelper(), //never cache
|
2015-01-13 19:38:23 +11:00
|
|
|
_logger, _sqlSyntax,
|
2012-12-10 08:44:17 -01:00
|
|
|
CreateRelationTypeRepository(uow));
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IRelationTypeRepository CreateRelationTypeRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
|
|
|
|
return new RelationTypeRepository(
|
|
|
|
|
uow,
|
2015-01-13 13:25:36 +11:00
|
|
|
CacheHelper.CreateDisabledCacheHelper(), //never cache
|
2015-01-13 19:38:23 +11:00
|
|
|
_logger, _sqlSyntax);
|
2012-12-10 08:44:17 -01:00
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual IScriptRepository CreateScriptRepository(IUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
2015-01-14 12:09:30 +11:00
|
|
|
return new ScriptRepository(uow, new PhysicalFileSystem(SystemDirectories.Scripts), _settings.Content);
|
2012-12-10 08:44:17 -01:00
|
|
|
}
|
|
|
|
|
|
Updates PartialView & PartialViewMacros models/services/repositories, streamlines their operations, fixes up other underlying problems with the FileRepository, fixes tree syncing for partial views, partial view macros and scripts, fixes scripts being created in folders, allows partial views and partial view macros to be managed and created in folders, fixes FileUnitOfWork to use a queue, publicizes some internal test classes, fixes tree syncing when dealing with invariant case, adds correct validation to the create dialogs of scripts and partial views (and partial view macros)
2014-10-22 16:44:45 +10:00
|
|
|
internal virtual IPartialViewRepository CreatePartialViewRepository(IUnitOfWork uow)
|
|
|
|
|
{
|
|
|
|
|
return new PartialViewRepository(uow);
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-09 18:39:44 +11:00
|
|
|
internal virtual IPartialViewRepository CreatePartialViewMacroRepository(IUnitOfWork uow)
|
Updates PartialView & PartialViewMacros models/services/repositories, streamlines their operations, fixes up other underlying problems with the FileRepository, fixes tree syncing for partial views, partial view macros and scripts, fixes scripts being created in folders, allows partial views and partial view macros to be managed and created in folders, fixes FileUnitOfWork to use a queue, publicizes some internal test classes, fixes tree syncing when dealing with invariant case, adds correct validation to the create dialogs of scripts and partial views (and partial view macros)
2014-10-22 16:44:45 +10:00
|
|
|
{
|
2015-01-09 18:39:44 +11:00
|
|
|
return new PartialViewMacroRepository(uow);
|
Updates PartialView & PartialViewMacros models/services/repositories, streamlines their operations, fixes up other underlying problems with the FileRepository, fixes tree syncing for partial views, partial view macros and scripts, fixes scripts being created in folders, allows partial views and partial view macros to be managed and created in folders, fixes FileUnitOfWork to use a queue, publicizes some internal test classes, fixes tree syncing when dealing with invariant case, adds correct validation to the create dialogs of scripts and partial views (and partial view macros)
2014-10-22 16:44:45 +10:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 09:24:05 -04:00
|
|
|
public virtual IStylesheetRepository CreateStylesheetRepository(IUnitOfWork uow, IDatabaseUnitOfWork db)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
2015-01-15 15:02:29 +11:00
|
|
|
return new StylesheetRepository(uow, new PhysicalFileSystem(SystemDirectories.Css));
|
2012-12-10 08:44:17 -01:00
|
|
|
}
|
|
|
|
|
|
2012-12-12 17:37:13 -01:00
|
|
|
public virtual ITemplateRepository CreateTemplateRepository(IDatabaseUnitOfWork uow)
|
2012-12-10 08:44:17 -01:00
|
|
|
{
|
2015-01-09 10:51:15 +11:00
|
|
|
return new TemplateRepository(uow,
|
2015-01-13 19:38:23 +11:00
|
|
|
_cacheHelper,
|
|
|
|
|
_logger, _sqlSyntax,
|
2015-01-09 10:51:15 +11:00
|
|
|
new PhysicalFileSystem(SystemDirectories.Masterpages),
|
|
|
|
|
new PhysicalFileSystem(SystemDirectories.MvcViews),
|
|
|
|
|
_settings.Templates);
|
2012-12-10 08:44:17 -01:00
|
|
|
}
|
2013-08-14 16:12:13 +02:00
|
|
|
|
|
|
|
|
internal virtual ServerRegistrationRepository CreateServerRegistrationRepository(IDatabaseUnitOfWork uow)
|
|
|
|
|
{
|
|
|
|
|
return new ServerRegistrationRepository(
|
|
|
|
|
uow,
|
2015-01-13 13:25:36 +11:00
|
|
|
CacheHelper.CreateDisabledCacheHelper(), //never cache
|
2015-01-13 19:38:23 +11:00
|
|
|
_logger, _sqlSyntax);
|
2013-08-14 16:12:13 +02:00
|
|
|
}
|
|
|
|
|
|
2014-02-20 21:56:58 +11:00
|
|
|
public virtual IUserTypeRepository CreateUserTypeRepository(IDatabaseUnitOfWork uow)
|
2013-08-14 16:12:13 +02:00
|
|
|
{
|
|
|
|
|
return new UserTypeRepository(
|
|
|
|
|
uow,
|
2014-01-06 11:56:53 +11:00
|
|
|
//There's not many user types but we query on users all the time so the result needs to be cached
|
2015-01-13 13:25:36 +11:00
|
|
|
_cacheHelper,
|
2015-01-13 19:38:23 +11:00
|
|
|
_logger, _sqlSyntax);
|
2013-08-14 16:12:13 +02:00
|
|
|
}
|
|
|
|
|
|
2014-02-20 21:56:58 +11:00
|
|
|
public virtual IUserRepository CreateUserRepository(IDatabaseUnitOfWork uow)
|
2014-01-28 10:46:59 +11:00
|
|
|
{
|
2013-08-14 16:12:13 +02:00
|
|
|
return new UserRepository(
|
|
|
|
|
uow,
|
2014-01-28 10:46:59 +11:00
|
|
|
//Need to cache users - we look up user information more than anything in the back office!
|
2015-01-13 13:25:36 +11:00
|
|
|
_cacheHelper,
|
2015-01-13 19:38:23 +11:00
|
|
|
_logger, _sqlSyntax,
|
2015-01-13 18:19:52 +11:00
|
|
|
CreateUserTypeRepository(uow));
|
2013-08-14 16:12:13 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-17 20:19:27 +10:00
|
|
|
internal virtual IMacroRepository CreateMacroRepository(IDatabaseUnitOfWork uow)
|
|
|
|
|
{
|
2015-01-13 13:25:36 +11:00
|
|
|
return new MacroRepository(uow,
|
|
|
|
|
_cacheHelper,
|
2015-01-13 19:38:23 +11:00
|
|
|
_logger, _sqlSyntax);
|
2013-09-17 20:19:27 +10:00
|
|
|
}
|
|
|
|
|
|
2014-02-20 21:56:58 +11:00
|
|
|
public virtual IMemberRepository CreateMemberRepository(IDatabaseUnitOfWork uow)
|
2013-08-26 16:59:41 +02:00
|
|
|
{
|
2014-02-11 19:21:36 +11:00
|
|
|
return new MemberRepository(
|
2014-02-13 16:46:52 +11:00
|
|
|
uow,
|
2015-01-13 13:25:36 +11:00
|
|
|
_cacheHelper,
|
2015-01-13 19:38:23 +11:00
|
|
|
_logger, _sqlSyntax,
|
2014-02-11 19:21:36 +11:00
|
|
|
CreateMemberTypeRepository(uow),
|
2014-02-13 16:46:52 +11:00
|
|
|
CreateMemberGroupRepository(uow),
|
2014-09-01 18:06:24 +10:00
|
|
|
CreateTagRepository(uow));
|
2013-08-26 16:59:41 +02:00
|
|
|
}
|
|
|
|
|
|
2014-02-20 21:56:58 +11:00
|
|
|
public virtual IMemberTypeRepository CreateMemberTypeRepository(IDatabaseUnitOfWork uow)
|
2013-09-02 15:53:09 +02:00
|
|
|
{
|
2015-01-13 13:25:36 +11:00
|
|
|
return new MemberTypeRepository(uow,
|
|
|
|
|
_cacheHelper,
|
2015-01-13 19:38:23 +11:00
|
|
|
_logger, _sqlSyntax);
|
2013-09-02 15:53:09 +02:00
|
|
|
}
|
|
|
|
|
|
2014-02-20 21:56:58 +11:00
|
|
|
public virtual IMemberGroupRepository CreateMemberGroupRepository(IDatabaseUnitOfWork uow)
|
2014-02-10 19:48:16 +11:00
|
|
|
{
|
2015-01-13 13:25:36 +11:00
|
|
|
return new MemberGroupRepository(uow,
|
2015-01-13 19:38:23 +11:00
|
|
|
_cacheHelper,
|
|
|
|
|
_logger, _sqlSyntax,
|
2015-01-09 10:51:15 +11:00
|
|
|
_cacheHelper);
|
2013-08-26 16:59:41 +02:00
|
|
|
}
|
|
|
|
|
|
2014-02-20 21:56:58 +11:00
|
|
|
public virtual IEntityRepository CreateEntityRepository(IDatabaseUnitOfWork uow)
|
2013-08-14 16:12:13 +02:00
|
|
|
{
|
|
|
|
|
return new EntityRepository(uow);
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-21 18:35:08 +11:00
|
|
|
public IDomainRepository CreateDomainRepository(IDatabaseUnitOfWork uow)
|
|
|
|
|
{
|
|
|
|
|
return new DomainRepository(uow, _cacheHelper, _logger, _sqlSyntax, CreateContentRepository(uow), CreateLanguageRepository(uow));
|
|
|
|
|
}
|
2015-01-22 19:19:21 +11:00
|
|
|
|
|
|
|
|
public ITaskTypeRepository CreateTaskTypeRepository(IDatabaseUnitOfWork uow)
|
|
|
|
|
{
|
|
|
|
|
return new TaskTypeRepository(uow,
|
|
|
|
|
CacheHelper.CreateDisabledCacheHelper(), //never cache
|
|
|
|
|
_logger, _sqlSyntax);
|
|
|
|
|
}
|
2012-12-10 08:44:17 -01:00
|
|
|
}
|
2012-12-09 09:01:00 +05:00
|
|
|
}
|