Permalink
Browse files

Remove the auth bundle from db creation and expose the plugins to ena…

…ble editing it
  • Loading branch information...
DanielDar committed Feb 10, 2013
1 parent 61d4c5d commit c7e50c17a634ed937a265e56caf01ad671359b4e
@@ -1078,6 +1078,9 @@
<Compile Include="..\Raven.Database\Bundles\SqlReplication\SqlReplicationStatus.cs">
<Link>Imports\SqlReplication\SqlReplicationStatus.cs</Link>
</Compile>
+ <Compile Include="..\Raven.Database\Plugins\PluginsStatus.cs">
+ <Link>Imports\Plugins\PluginsStatus.cs</Link>
+ </Compile>
<Compile Include="Connection\HttpJsonRequest.cs" />
<Compile Include="Connection\HttpJsonRequestFactory.cs" />
<Compile Include="Connection\HttpJsonRequestHelper.cs" />
@@ -0,0 +1,14 @@
+using System.Collections.Generic;
+
+namespace Raven.Database.Plugins
+{
+ public class PluginsStatus
+ {
+ public List<string> Plugins { get; set; }
+
+ public PluginsStatus()
+ {
+ Plugins = new List<string>();
+ }
+ }
+}
@@ -232,6 +232,7 @@
<Compile Include="Linq\Mono.Reflection\MethodBodyReader.cs" />
<Compile Include="Linq\PrivateExtensions\DynamicEnumerable.cs" />
<Compile Include="Linq\StringLiteralExpression.cs" />
+ <Compile Include="Plugins\PluginsStatus.cs" />
<Compile Include="Queries\MoreLikeThisQueryRunner.cs" />
<Compile Include="Queries\MoreLikeThisQueryExtensions.cs" />
<Compile Include="Queries\MatchNoDocsQuery.cs" />
@@ -371,6 +372,7 @@
<Compile Include="Server\Responders\Licensing.cs" />
<Compile Include="Server\Responders\Logs.cs" />
<Compile Include="Server\Responders\OperationStatus.cs" />
+ <Compile Include="Server\Responders\Plugins.cs" />
<Compile Include="Server\Responders\RavenRoot.cs" />
<Compile Include="Server\Responders\RavenUI.cs" />
<Compile Include="Server\Responders\SilverlightUI.cs" />
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using Raven.Database.Extensions;
+using Raven.Database.Plugins;
+using Raven.Database.Server.Abstractions;
+
+namespace Raven.Database.Server.Responders
+{
+ class Plugins : AbstractRequestResponder
+ {
+ public override string UrlPattern
+ {
+ get { return "^/plugins/status$"; }
+ }
+
+ public override string[] SupportedVerbs
+ {
+ get { return new[] { "GET" }; }
+ }
+
+ public override void Respond(IHttpContext context)
+ {
+ var dir = SystemDatabase.Configuration.PluginsDirectory;
+ if (Directory.Exists(dir) == false)
+ {
+ context.WriteJson(new PluginsStatus());
+ return;
+ }
+
+ var plugins = new PluginsStatus { Plugins = Directory.GetFiles(dir).Where(s => s.EndsWith(".dll")).Select(Path.GetFileName).ToList() };
+
+
+ context.WriteJson(plugins);
+ }
+ }
+}
@@ -212,30 +212,12 @@ private void HandleBundleAfterCreation(CreateSettingsModel settingsModel, string
}
}
-
- var authorizationSection = settingsModel.GetSection<AuthorizationSettingsSectionModel>();
- if (authorizationSection != null)
- StoreAuthorizationData(authorizationSection, session);
-
session.SaveChangesAsync();
if (!string.IsNullOrEmpty(encryptionKey))
new ShowEncryptionMessage(encryptionKey).Show();
}
- private void StoreAuthorizationData(AuthorizationSettingsSectionModel authorizationSection, IAsyncDocumentSession session)
- {
- foreach (var authorizationRole in authorizationSection.AuthorizationRoles)
- {
- session.Store(authorizationRole);
- }
-
- foreach (var authorizationUser in authorizationSection.AuthorizationUsers)
- {
- session.Store(authorizationUser);
- }
- }
-
private void StoreVersioningData(IEnumerable<VersioningConfiguration> versioningData, IAsyncDocumentSession session)
{
foreach (var data in versioningData)
@@ -104,7 +104,6 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
@@ -198,26 +197,13 @@
MouseLeftButtonDown="ToggleBundles"
ToolTipService.ToolTip="{Binding ElementName=NewDatabaseControl, Path=LicensingStatus.Value, Converter={StaticResource BundleNameToToolTip}, ConverterParameter=Versioning}"/>
- <CheckBox x:Name="Authorization"
- Checked="Checked"
- Unchecked="UnChecked"
- Grid.Row="7"
- Margin="5"
- IsEnabled="{Binding ElementName=NewDatabaseControl, Path=LicensingStatus.Value, Converter={StaticResource BundleNameToActive}, ConverterParameter=Authorization}"/>
- <TextBlock Grid.Column="1"
- Grid.Row="7"
- Text="Authorization Bundle"
- Margin="5"
- MouseLeftButtonDown="ToggleBundles"
- ToolTipService.ToolTip="{Binding ElementName=NewDatabaseControl, Path=LicensingStatus.Value, Converter={StaticResource BundleNameToToolTip}, ConverterParameter=Authorization}"/>
-
<CheckBox x:Name="Periodic"
- Grid.Row="8"
+ Grid.Row="7"
Margin="5"
IsChecked="{Binding ElementName=NewDatabaseControl, Path=LicensingStatus.Value, Converter={StaticResource BundleNameToActive}, ConverterParameter=PeriodicBackup}"
IsEnabled="False"/>
<TextBlock Grid.Column="1"
- Grid.Row="8"
+ Grid.Row="7"
Text="Periodic Backup Bundle"
Margin="5"
MouseLeftButtonDown="ToggleBundles"
@@ -4,6 +4,7 @@
using Raven.Abstractions.Data;
using Raven.Client.Connection;
using Raven.Client.Document;
+using Raven.Database.Plugins;
using Raven.Json.Linq;
using Raven.Studio.Commands;
using Raven.Studio.Infrastructure;
@@ -84,6 +85,20 @@ protected override void OnViewLoaded()
{
settingsSectionModel.LoadFor(databaseDocument);
}
+
+ var req = ApplicationModel.DatabaseCommands.ForSystemDatabase().CreateRequest("/plugins/status".NoCache(), "GET");
+
+ req.ReadResponseJsonAsync().ContinueOnSuccessInTheUIThread(item =>
+ {
+ var plugins = ((RavenJObject)item).Deserialize<PluginsStatus>(new DocumentConvention());
+
+ if (plugins == null || plugins.Plugins.Contains("Raven.Bundles.Authorization.dll") == false)
+ return;
+
+ var authSection = new AuthorizationSettingsSectionModel();
+ Settings.Sections.Add(authSection);
+ authSection.LoadFor(databaseDocument);
+ });
});
}

0 comments on commit c7e50c1

Please sign in to comment.