예제 #1
0
        public Task DeleteApiKey()
        {
            TransactionOperationContext ctx;

            using (ServerStore.ContextPool.AllocateOperationContext(out ctx))
            {
                var name = HttpContext.Request.Query["name"];

                if (name.Count != 1)
                {
                    HttpContext.Response.StatusCode = 400;
                    return(HttpContext.Response.WriteAsync("'name' query string must have exactly one value"));
                }

                using (var tx = ctx.OpenWriteTransaction())
                {
                    ServerStore.Delete(ctx, Constants.ApiKeyPrefix + name[0]);

                    tx.Commit();
                }
                AccessToken value;
                if (Server.AccessTokensByName.TryRemove(name[0], out value))
                {
                    Server.AccessTokensById.TryRemove(value.Token, out value);
                }
                return(Task.CompletedTask);
            }
        }
예제 #2
0
        private void DeleteDatabase(string name, TransactionOperationContext context, bool isHardDelete, RavenConfiguration configuration)
        {
            ServerStore.DatabasesLandlord.UnloadAndLock(name, () =>
            {
                var dbId = Constants.Database.Prefix + name;
                using (var tx = context.OpenWriteTransaction())
                {
                    ServerStore.Delete(context, dbId);
                    tx.Commit();
                }

                if (isHardDelete)
                {
                    DatabaseHelper.DeleteDatabaseFiles(configuration);
                }
            });
        }