public AzureOutputCacheStorageProvider(ShellSettings shellSettings, IAzureOutputCacheHolder cacheHolder, IPlatformConfigurationAccessor pca) {

            var region = shellSettings.Name;

            // Azure Cache supports only alphanumeric strings for regions, but Orchard supports some
            // non-alphanumeric characters in tenant names. Remove all non-alphanumering characters
            // from the region, and append the hash code of the original string to mitigate the risk
            // of two distinct original region strings yielding the same transformed region string.
            _regionAlphaNumeric = new String(Array.FindAll(region.ToCharArray(), Char.IsLetterOrDigit)) + region.GetHashCode().ToString(CultureInfo.InvariantCulture);

            _cache = cacheHolder.TryGetDataCache(() => {
                CacheClientConfiguration cacheConfig;

                try {
                    cacheConfig = CacheClientConfiguration.FromPlatformConfiguration(shellSettings.Name, Constants.OutputCacheSettingNamePrefix, pca);
                    cacheConfig.Validate();
                }
                catch (Exception ex) {
                    throw new Exception(String.Format("The {0} configuration settings are missing or invalid.", Constants.OutputCacheFeatureName), ex);
                }

                var cache = cacheConfig.CreateCache();
                cache.CreateRegion(_regionAlphaNumeric);

                return cache;
            });
        }
 public static CacheClientConfiguration FromPlatformConfiguration(string tenant, string settingNamePrefix, IPlatformConfigurationAccessor pca) {
     return new CacheClientConfiguration {
         HostIdentifier = pca.GetSetting(Constants.CacheHostIdentifierSettingName, tenant, settingNamePrefix),
         CacheName = pca.GetSetting(Constants.CacheCacheNameSettingName, tenant, settingNamePrefix),
         AuthorizationToken = pca.GetSetting(Constants.CacheAuthorizationTokenSettingName, tenant, settingNamePrefix),
     };
 }
 protected override void OnInit()
 {
     CloudStorageAccount.TryParse("UseDevelopmentStorage=true", out _devAccount);
     _platformConfigurationAccessor = new DefaultPlatformConfigurationAccessor();
     _azureBlobStorageProvider      = new AzureBlobStorageProvider(new ShellSettings {
         Name = "default"
     }, new ConfigurationMimeTypeProvider(), _platformConfigurationAccessor);
 }
Пример #4
0
 public AzureBlobStorageProvider(ShellSettings shellSettings, IMimeTypeProvider mimeTypeProvider, IPlatformConfigurationAccessor pca)
     : this(pca.GetSetting(Constants.MediaStorageStorageConnectionStringSettingName, shellSettings.Name, null),
            Constants.MediaStorageContainerName,
            pca.GetSetting(Constants.MediaStorageRootFolderPathSettingName, shellSettings.Name, null) ?? shellSettings.Name,
            mimeTypeProvider,
            pca.GetSetting(Constants.MediaStoragePublicHostName, shellSettings.Name, null))
 {
 }
Пример #5
0
        public MigrateMediaService(IMediaLibraryService mediaLibraryService, IMimeTypeProvider mimeTypeProvider, IPlatformConfigurationAccessor platformConfigurationAccessor, IStorageProvider storageProvider, ShellSettings shellSettings)
        {
            _mediaLibraryService           = mediaLibraryService;
            _mimeTypeProvider              = mimeTypeProvider;
            _platformConfigurationAccessor = platformConfigurationAccessor;
            _storageProvider = storageProvider;
            _shellSettings   = shellSettings;

            Logger = NullLogger.Instance;
        }
Пример #6
0
 public AzureBlobStorageProvider(
     ShellSettings shellSettings,
     IMimeTypeProvider mimeTypeProvider,
     IPlatformConfigurationAccessor platformConfigurationAccessor)
     : this(platformConfigurationAccessor.GetSetting(Constants.MediaStorageStorageConnectionStringSettingName, shellSettings.Name, null),
            platformConfigurationAccessor.GetSetting(Constants.MediaStorageContainerNameSettingName, shellSettings.Name, null) ?? Constants.MediaStorageDefaultContainerName,
            platformConfigurationAccessor.GetSetting(Constants.MediaStorageRootFolderPathSettingName, shellSettings.Name, null) ?? shellSettings.Name,
            mimeTypeProvider,
            platformConfigurationAccessor.GetSetting(Constants.MediaStoragePublicHostName, shellSettings.Name, null))
 {
 }
 public AzureBlobStorageProvider(ShellSettings shellSettings, IMimeTypeProvider mimeTypeProvider, IPlatformConfigurationAccessor pca)
     : this(pca.GetSetting(Orchard.Azure.Constants.MediaStorageStorageConnectionStringSettingName, shellSettings.Name, null),
            Orchard.Azure.Constants.MediaStorageContainerName,
            pca.GetSetting(Orchard.Azure.Constants.MediaStorageRootFolderPathSettingName, shellSettings.Name, null) ?? shellSettings.Name,
            mimeTypeProvider,
            pca.GetSetting(Orchard.Azure.Constants.MediaStoragePublicHostName, shellSettings.Name, null))
 {
     if (pca != null && shellSettings != null)
     {
         _cacheControl = pca.GetSetting(Constants.MediaStorageCacheControlName, shellSettings.Name, null);
     }
 }
        public AzureOutputCacheStorageProvider(
            ShellSettings shellSettings,
            IPlatformConfigurationAccessor pca,
            ICacheManager cacheManager)
        {
            _cacheManager  = cacheManager;
            _shellSettings = shellSettings;
            _pca           = pca;

            var region = shellSettings.Name;

            // Azure Cache supports only alphanumeric strings for regions, but Orchard supports some
            // non-alphanumeric characters in tenant names. Remove all non-alphanumering characters
            // from the region, and append the hash code of the original string to mitigate the risk
            // of two distinct original region strings yielding the same transformed region string.
            _regionAlphaNumeric = new String(Array.FindAll(region.ToCharArray(), Char.IsLetterOrDigit)) + region.GetHashCode().ToString(CultureInfo.InvariantCulture);

            Logger = NullLogger.Instance;
        }
 public static CacheClientConfiguration FromPlatformConfiguration(string tenant, string settingNamePrefix, IPlatformConfigurationAccessor pca)
 {
     return(new CacheClientConfiguration {
         HostIdentifier = pca.GetSetting(Constants.CacheHostIdentifierSettingName, tenant, settingNamePrefix),
         CacheName = pca.GetSetting(Constants.CacheCacheNameSettingName, tenant, settingNamePrefix),
         AuthorizationToken = pca.GetSetting(Constants.CacheAuthorizationTokenSettingName, tenant, settingNamePrefix),
     });
 }
        public AzureOutputCacheStorageProvider(ShellSettings shellSettings, IAzureOutputCacheHolder cacheHolder, IPlatformConfigurationAccessor pca)
        {
            var region = shellSettings.Name;

            // Azure Cache supports only alphanumeric strings for regions, but Orchard supports some
            // non-alphanumeric characters in tenant names. Remove all non-alphanumering characters
            // from the region, and append the hash code of the original string to mitigate the risk
            // of two distinct original region strings yielding the same transformed region string.
            _regionAlphaNumeric = new String(Array.FindAll(region.ToCharArray(), Char.IsLetterOrDigit)) + region.GetHashCode().ToString(CultureInfo.InvariantCulture);

            _cache = cacheHolder.TryGetDataCache(() => {
                CacheClientConfiguration cacheConfig;

                try {
                    cacheConfig = CacheClientConfiguration.FromPlatformConfiguration(shellSettings.Name, Constants.OutputCacheSettingNamePrefix, pca);
                    cacheConfig.Validate();
                }
                catch (Exception ex) {
                    throw new Exception(String.Format("The {0} configuration settings are missing or invalid.", Constants.OutputCacheFeatureName), ex);
                }

                var cache = cacheConfig.CreateCache();
                cache.CreateRegion(_regionAlphaNumeric);

                return(cache);
            });
        }
Пример #11
0
 public AzureBlobStorageProvider(ShellSettings shellSettings, IMimeTypeProvider mimeTypeProvider, IPlatformConfigurationAccessor pca)
     : this(pca.GetSetting(Constants.MediaStorageStorageConnectionStringSettingName, shellSettings.Name, null),
            Constants.MediaStorageContainerName, shellSettings.Name, mimeTypeProvider,
            pca.GetSetting(Constants.MediaStoragePublicHostName, shellSettings.Name, null))
 {
 }
 public LuceneAzureFileSystemFactory(IPlatformConfigurationAccessor pca)
 {
     _pca = pca;
 }
        public SecuredAzureBlobStorageProvider(ShellSettings shellSettings, IMimeTypeProvider mimeTypeProvider, IPlatformConfigurationAccessor pca)
            : this(pca.GetSetting(global::Orchard.Azure.Constants.MediaStorageStorageConnectionStringSettingName, shellSettings.Name, null),
                   global::Orchard.Azure.Constants.MediaStorageContainerName,
                   pca.GetSetting(global::Orchard.Azure.Constants.MediaStorageRootFolderPathSettingName, shellSettings.Name, null) ?? shellSettings.Name,
                   mimeTypeProvider,
                   pca.GetSetting(global::Orchard.Azure.Constants.MediaStoragePublicHostName, shellSettings.Name, null))
        {
            var mediaPath = HostingEnvironment.IsHosted
                                ? HostingEnvironment.MapPath("~/" + SECURE_MEDIA_PATH + "/") ?? ""
                                : Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SECURE_MEDIA_PATH);

            var appPath = "";

            if (HostingEnvironment.IsHosted)
            {
                appPath = HostingEnvironment.ApplicationVirtualPath;
            }
            if (!appPath.EndsWith("/"))
            {
                appPath = appPath + '/';
            }
            if (!appPath.StartsWith("/"))
            {
                appPath = '/' + appPath;
            }

            _publicPath = appPath + SECURE_MEDIA_PATH + "/" + shellSettings.Name + "/";
        }
Пример #14
0
 public AzureBlobStorageProvider(ShellSettings shellSettings, IMimeTypeProvider mimeTypeProvider, IPlatformConfigurationAccessor pca)
     : this(pca.GetSetting(Orchard.Azure.Constants.MediaStorageStorageConnectionStringSettingName, shellSettings.Name, null),
            Orchard.Azure.Constants.MediaStorageDefaultContainerName,
            pca.GetSetting(Orchard.Azure.Constants.MediaStorageRootFolderPathSettingName, shellSettings.Name, null) ?? shellSettings.Name,
            mimeTypeProvider,
            pca.GetSetting(Orchard.Azure.Constants.MediaStoragePublicHostName, shellSettings.Name, null))
 {
     if (pca != null && shellSettings != null)
     {
         _cacheControl = pca.GetSetting(Constants.MediaStorageCacheControlName, shellSettings.Name, null);
     }
 }
Пример #15
0
 public LuceneAzureFileSystemFactory(IPlatformConfigurationAccessor pca)
 {
     _pca = pca;
 }