/// <summary>
        /// Sets up the Storage Provider.
        /// </summary>
        /// <param name="host">The Host of the Component.</param>
        /// <param name="config">The Configuration data, if any.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="host"/> or <paramref name="config"/> are <c>null</c>.</exception>
        /// <exception cref="InvalidConfigurationException">If <paramref name="config"/> is not valid or is incorrect.</exception>
        public void SetUp(IHostV40 host, string config)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (config == "")
            {
                config = Config.GetConnectionString();
            }

            TableStorage.CreateTable(config, GlobalSettingsTable);
            TableStorage.CreateTable(config, LogsTable);

            _client = TableStorage.StorageAccount(config).CreateCloudBlobClient();

            CloudBlobContainer containerRef = _client.GetContainerReference(AssembliesContainer);

            containerRef.CreateIfNotExist();
        }
Beispiel #2
0
        /// <summary>
        /// Initializes the Storage Provider.
        /// </summary>
        /// <param name="host">The Host of the Component.</param>
        /// <param name="config">The Configuration data, if any.</param>
        /// <param name="wiki">The wiki.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="host"/> or <paramref name="config"/> are <c>null</c>.</exception>
        /// <exception cref="InvalidConfigurationException">If <paramref name="config"/> is not valid or is incorrect.</exception>
        public void Init(IHostV50 host, string config, string wiki)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (config == "")
            {
                config = Config.GetConnectionString();
            }

            _host = host;
            _wiki = string.IsNullOrEmpty(wiki) ? "root" : wiki.ToLowerInvariant();

            _client = TableStorage.StorageAccount(config).CreateCloudBlobClient();

            CloudBlobContainer containerRef = _client.GetContainerReference(_wiki);

            containerRef.CreateIfNotExists();

            containerRef = _client.GetContainerReference(_wiki + "-attachments");
            containerRef.CreateIfNotExists();
        }
        /// <summary>
        /// Initializes the Storage Provider.
        /// </summary>
        /// <param name="host">The Host of the Component.</param>
        /// <param name="config">The Configuration data, if any.</param>
        /// <param name="wiki">The wiki.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="host"/> or <paramref name="config"/> are <c>null</c>.</exception>
        /// <exception cref="InvalidConfigurationException">If <paramref name="config"/> is not valid or is incorrect.</exception>
        public void Init(IHostV50 host, string config, string wiki)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (config == "")
            {
                config = Config.GetConnectionString();
            }

            _host = host;
            _wiki = string.IsNullOrEmpty(wiki) ? "root" : wiki.ToLowerInvariant();

            _client = TableStorage.StorageAccount(config).CreateCloudBlobClient();

            CloudBlobContainer       containerRef = _client.GetContainerReference(_wiki + "-themes");
            BlobContainerPermissions permissions  = new BlobContainerPermissions();

            permissions.PublicAccess = BlobContainerPublicAccessType.Blob;
            containerRef.CreateIfNotExists();
            containerRef.SetPermissions(permissions);
        }
Beispiel #4
0
        /// <summary>
        /// Deletes all blobs in all containers.
        /// Used only in tests tear-down method
        /// </summary>
        /// <param name="connectionString">The connection string.</param>
        public static void DeleteAllBlobs(string connectionString)
        {
            CloudBlobClient _client = TableStorage.StorageAccount(connectionString).CreateCloudBlobClient();

            _client.DefaultRequestOptions = GetDefaultBlobRequestOptions();

            foreach (CloudBlobContainer containerRef in _client.ListContainers())
            {
                IEnumerable <IListBlobItem> blobs = containerRef.ListBlobs(useFlatBlobListing: true);
                foreach (IListBlobItem blob in blobs)
                {
                    var blobRef = _client.GetBlobReferenceFromServer(blob.Uri); // v.1.7: GetBlobReference(blob.Uri.AbsoluteUri)
                    blobRef.DeleteIfExists();
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Deletes all blobs in all containers.
        /// Used only in tests tear-down method
        /// </summary>
        /// <param name="connectionString">The connection string.</param>
        public static void DeleteAllBlobs(string connectionString)
        {
            CloudBlobClient _client = TableStorage.StorageAccount(connectionString).CreateCloudBlobClient();

            _client.RetryPolicy = GetDefaultRetryPolicy();

            foreach (CloudBlobContainer containerRef in _client.ListContainers())
            {
                BlobRequestOptions options = new BlobRequestOptions();
                options.UseFlatBlobListing = true;
                IEnumerable <IListBlobItem> blobs = containerRef.ListBlobs(options);
                foreach (IListBlobItem blob in blobs)
                {
                    var blobRef = _client.GetBlobReference(blob.Uri.AbsoluteUri);
                    blobRef.DeleteIfExists();
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// Initializes the Storage Provider.
        /// </summary>
        /// <param name="host">The Host of the Component.</param>
        /// <param name="config">The Configuration data, if any.</param>
        /// <param name="wiki">The wiki.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="host"/> or <paramref name="config"/> are <c>null</c>.</exception>
        /// <exception cref="InvalidConfigurationException">If <paramref name="config"/> is not valid or is incorrect.</exception>
        public void Init(IHostV40 host, string config, string wiki)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (config == "")
            {
                config = Config.GetConnectionString();
            }

            _host = host;
            _wiki = string.IsNullOrEmpty(wiki) ? "root" : wiki;

            _directory = new AzureDirectory(TableStorage.StorageAccount(config), wiki + "-searchindex");
        }
        /// <summary>
        /// Initializes the Storage Provider.
        /// </summary>
        /// <param name="host">The Host of the Component.</param>
        /// <param name="config">The Configuration data, if any.</param>
        /// <param name="wiki">The wiki.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="host"/> or <paramref name="config"/> are <c>null</c>.</exception>
        /// <exception cref="InvalidConfigurationException">If <paramref name="config"/> is not valid or is incorrect.</exception>
        public void Init(IHostV40 host, string config, string wiki)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (config == "")
            {
                config = Config.GetConnectionString();
            }

            _host = host;
            _wiki = wiki;

            _context = TableStorage.GetContext(config);

            _client = TableStorage.StorageAccount(config).CreateCloudBlobClient();
        }